Issue
When I open a server with gunicorn for my flask app, it automatically opens the development server of flask, without giving me any errors:
$ gunicorn3 --workers=1 main:app
\[2023-10-16 19:46:13 +0000\] \[1061\] \[INFO\] Starting gunicorn 20.1.0
\[2023-10-16 19:46:13 +0000\] \[1061\] \[INFO\] Listening at: http://127.0.0.1:8000 (1061)
\[2023-10-16 19:46:13 +0000\] \[1061\] \[INFO\] Using worker: sync
\[2023-10-16 19:46:13 +0000\] \[1062\] \[INFO\] Booting worker with pid: 1062
* Serving Flask app 'app'
* Debug mode: off
2023-10-16 19:46:14,209:INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
2023-10-16 19:46:14,209:INFO - Press CTRL+C to quit
I already have other servers with gunicorn and I don't understand this behavior, does someone know?
I've changed the port and the host, but the outcome is the same, also with the debug mode and the number of workers of gunicorn3.
Solution
If you have the following lines in your main application script then it will cause Flask's development server to start
if __name__ == '__main__':
app.run()
- You could comment out the above part
- Make sure that you don't have any environment variables like
FLASK_ENV=development
orFLASK_APP=app.py
- Confirm that
main:app
correctly points to your Flask application object
Answered By - Yuri R
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.