I am developing a flask webapp, and during development I test my app with run.py
.
run.py:
from my_app import app
from my_app.config import (WEBSERVER_PORT)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=WEBSERVER_PORT, debug=True)
However, I am planning to serve my app with gunicorn in production and I am seeing descrepencies when I run the app with gunicorn. For example, I added a new button to my webapp, and I can only see the new button with I use run.py
to run the app. But when I use gunicorn to serve my app like this:
gunicorn --bind 0.0.0.0:8000 wsgi
The app runs with no errors, however, I don't see the new button. Here is my wsgi.py:
from my_app import app as application
if __name__ == "__main__":
application.run()
And here is how I serve it:
(venv)# gunicorn --bind 0.0.0.0:8000 wsgi
[2018-11-19 10:35:52 -0800] [16644] [INFO] Starting gunicorn 19.9.0
[2018-11-19 10:35:52 -0800] [16644] [INFO] Listening at: http://0.0.0.0:8000 (16644)
[2018-11-19 10:35:52 -0800] [16644] [INFO] Using worker: sync
[2018-11-19 10:35:52 -0800] [16647] [INFO] Booting worker with pid: 16647
So my question is, does Gunicorn cache any of your changes, because I only see my old code when serving with gunicorn. Or is there anything I have to do to get the new changes in before running it with Gunicorn?