2

I have a Flask application i want to run with Gunicorn server instead of Werkzeug (even in development). But as the app is created using a create_app function, Gunicorn can't be started from the command line with my_module:my_app. Plus, i have a manage.py script written with the help of Flask-Script extension to run the server and some other operations.

I've tried to inherit gunicorn.app.wsgiapp.WSGIApplication in the same style as the solution proposed here: How to use Flask-Script and Gunicorn, but the app_uri attribute is not found on my app object.

Does anyone have an idea of how to do it ?

Community
  • 1
  • 1
phndiaye
  • 309
  • 4
  • 19

2 Answers2

7

You're missing the same obvious thing I once did. ;)

gunicorn 'my_module:create_app()'
mikenerone
  • 1,937
  • 3
  • 15
  • 19
3

I solved this problem using the recipe in the Custom Application section of the Gunicorn documentation. The basic idea is that you subclass gunicorn.app.base.BaseApplication and overload load_config and load.

Tom Ellis
  • 9,224
  • 1
  • 29
  • 54