gpt4 book ai didi

python - 如何在gunicorn中查看python应用程序的错误

转载 作者:太空宇宙 更新时间:2023-11-03 16:11:13 25 4
gpt4 key购买 nike

我有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.

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

最佳答案

这是gunicorn日志(不是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()

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

关于python - 如何在gunicorn中查看python应用程序的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39295358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com