python - 如何让uWSGI遇到错误时死掉?

标签 python uwsgi supervisord

我的 Python 应用程序通过 uWSGI 运行。应用程序很少会遇到导致无法加载的错误。此时,如果我向 uWSGI 发送请求,我会收到错误no python application found, check yourstarting log forErrors。在这种情况下我希望发生的事情是让 uWSGI 死掉,以便管理它的程序(在我的例子中是 Supervisor)可以重新启动它。是否有设置或其他东西可以用来强制执行此操作?

有关我的设置的更多信息: Python 2.7 应用程序在 Docker 容器中通过 uWSGI 运行。 docker容器由Supervisor管理,如果它死了,Supervisor将重新启动它,这就是我想要发生的事情。

最佳答案

经过一个小时的搜索,我终于找到了一种方法。只需在启动 uWSGI 时传递 --need-app 参数,或者在您的 .ini 文件中添加 need-app = true(如果您以这种方式运行)。不知道为什么默认情况下这是关闭的(在什么情况下,当你的应用程序死掉时,你会希望 uWSGI 继续运行?),但事情就是这样。

关于python - 如何让uWSGI遇到错误时死掉?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40096695/

相关文章:

python - uwsgi 和 django - django uwsgi 导入正在离开 virtualenv 并崩溃

docker - uWSGI应用程式中缺少Nginx header ( flask )

django - celery 击败服务旧(删除)任务

Python Telethon get_messages 偏移量

python - 如何在 python 的 turtle 图形中旋转文本

python - Sqlalchemy 返回 SELECT 命令的不同结果(query.all)

php - 使用主管的 Laravel 5.8 异步队列问题

django - 获取 pkg_resources.DistributionNotFound : The 'supervisor==3.2.0' distribution was not found and is required by the application?

Python 3.4并发.futures.Executor不提供暂停和恢复线程的控制

python - 尝试导入 python 模块时的疯狂行为