Debugging a Flask app running in Gunicorn

后端 未结 6 844
遇见更好的自我
遇见更好的自我 2020-11-29 17:31

I\'ve been working on a new dev platform using nginx/gunicorn and Flask for my application.

Ops-wise, everything works fine - the issue I\'m having is with debugging

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 17:53

    I had similiar problem when running flask under gunicorn I didn't see stacktraces in browser (had to look at logs every time). Setting DEBUG, FLASK_DEBUG, or anything mentioned on this page didn't work. Finally I did this:

    app = Flask(__name__)
    app.config.from_object(settings_map[environment])
    if environment == 'development':
        from werkzeug.debug import DebuggedApplication
        app_runtime = DebuggedApplication(app, evalex=False)
    else:
        app_runtime = app
    

    Note evalex is disabled because interactive debbugging won't work with forking (gunicorn).

提交回复
热议问题