0

When I run the flask server in local machine, I use this code

app.run(host='0.0.0.0', port=port,debug=False,use_reloader=False) 

I am using BackgroundScheduler so I need reloader to be false othrwise BackgroundScheduler will run twice.

from apscheduler.schedulers.background import BackgroundScheduler 

When I deploy to Heroku, I use gunicorn like this

web: gunicorn app:app 

So the problem is that reloader is true when using this so BackgroundScheduler has two instances.
So how do I stop reloader for Gunicorn?
Any help will be appreciated.

fl

As you can see in above image 2 processes are created.
Thank you in advance

1 Answer 1

1

You can just provide the same arguments as command line arguments in heroku:

web: gunicorn app:app --reload=False

This does provide an answer to your question, but it won't solve the issue, as the default value for --reload is already False. You can check that with gunicorn --help.

I think you shouldn't use BackgroundScheduler, but instead use the --daemon flag. As per gunicorn --help : -D, --daemon - Daemonize the Gunicorn process. [False]. "To Daemonize" means run it as a background process.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your help, I will look into this. I found another working solution for my problem which is to use --preload which worked for me.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.