【问题标题】:How to see error for python application in gunicorn如何在 gunicorn 中查看 python 应用程序的错误
【发布时间】:2016-09-02 14:53:52
【问题描述】:

我有 falcon 使用 gunicorn 运行的应用程序。如果 .py 文件中有错误,它会提供回溯,但在 grunicorn 中它只发送到控制台:

[2016-09-02 17:39:26 +0300] [6927] [INFO] Starting gunicorn 19.6.0
[2016-09-02 17:39:26 +0300] [6927] [INFO] Listening at: http://127.0.0.1:8000 (6927)
[2016-09-02 17:39:26 +0300] [6927] [INFO] Using worker: sync
[2016-09-02 17:39:26 +0300] [6930] [INFO] Booting worker with pid: 6930

唯一的错误输出是:

[2016-09-02 17:39:29 +0300] [6927] [INFO] Shutting down: Master
[2016-09-02 17:39:29 +0300] [6927] [INFO] Reason: Worker failed to boot.

如何获得完整的错误输出?我需要知道导致 worker 无法启动的原因。

【问题讨论】:

    标签: python error-handling gunicorn falconframework


    【解决方案1】:

    这是 gunicorn 日志(不是 falcon)的问题。有时它不会输出导致启动失败的异常。所以调试我的WSGIapp我通常做的是用wsgiref提供的测试服务器运行服务器,如下:

    from wsgiref import simple_server
    
    if __name__ == '__main__':
        APP_HOST = 8080 #you may want to change this
        APP_HOST = '0.0.0.0' #you may want to change this
        httpd = simple_server.make_server(APP_HOST, APP_PORT, app)
        httpd.serve_forever()
    

    这应该可以帮助您找出问题所在。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-11
      • 2013-01-29
      • 2011-04-30
      • 2022-11-24
      • 2012-07-24
      • 2014-03-23
      • 2014-01-18
      • 1970-01-01
      相关资源
      最近更新 更多