1

我有使用 gunicorn 运行的falcon应用程序。如果 .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.

如何获得完整的错误输出?我需要知道是什么导致工人无法启动。

4

1 回答 1

1

这是 gunicorn log(不是 falcon)的问题。有时它不会输出导致启动失败的异常。所以要调试我的 WSGI app,我通常做的是使用提供的测试服务器运行服务器,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()

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

于 2016-09-02T21:19:34.237 回答