gpt4 book ai didi

python - gunicorn 不在 supervisord 下工作(但自己工作)

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:07:29 26 4
gpt4 key购买 nike

我在监督下运行 gunicorn 没有任何问题,这个周末它停止工作了。

什么时候 application start inside supervisorctl 这是在应用程序日志中:

Traceback (most recent call last):
File "/usr/local/bin/gunicorn", line 9, in <module>
load_entry_point('gunicorn==19.0.0', 'console_scripts', 'gunicorn')()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 74, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 166, in run
super(Application, self).run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 71, in run
Arbiter(self).run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 192, in run
self.halt()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 292, in halt
self.stop()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 343, in stop
time.sleep(0.1)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 209, in handle_chld
self.reap_workers()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 459, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

我正在使用此配置运行应用程序:

[program:application]
command=/usr/local/bin/gunicorn application:application -c /home/azureuser/rz-app/gunicorn.conf.py
directory=/home/azureuser/rz-app/
user=root
autostart=true
autorestart=true
redirect_stderr=True
stdout_logfile = /home/azureuser/rz-app/rz-app_log.log
stderr_logfile = /home/azureuser/rz-app/rz-app_errors.log

gunicorn.conf.py 的内容如下:

import multiprocessing

bind = "0.0.0.0:5000"

workers = multiprocessing.cpu_count() * 4 + 1
user = 'root'
group = 'root'

max_requests = 200
max_requests_jitter = 20

如果我在主管之外的终端上运行命令:gunicorn application:application -c gunicorn.conf.py 事情按预期工作。

这是一个 Flask 应用程序,这里是 application.py 文件:

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

import socket
socket.setdefaulttimeout(12)

from werkzeug.contrib.fixers import ProxyFix

from app import application
application.wsgi_app = ProxyFix(application.wsgi_app)


if __name__ == '__main__':

application.run(host='0.0.0.0', port=5000, debug=False)

我该如何解决这个问题?

编辑:我注意到这似乎是 root 用户的问题,在外部主管时,我运行了:

sudo/usr/local/bin/gunicorn application:application -c/home/azureuser/rz-app/gunicorn.conf.py,一切正常,但当我这样做时:

sudo su 后跟 /usr/local/bin/gunicorn application:application -c/home/azureuser/rz-app/gunicorn.conf.py 它没有'工作

最佳答案

发现问题,它与 gunicorn 或 supervisor 无关,我的应用程序有一个仅在用户中下载的依赖项,我注意到当我在命令之前执行 sudo su 时,出现了同样的问题,所以我记录了在成为 root /usr/local/bin/gunicorn --log-file=- application:application -c/home/azureuser/rz-app/gunicorn.conf.py 时发生的事情,添加--log-file=- 并找出困扰我的错误。

关于python - gunicorn 不在 supervisord 下工作(但自己工作),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31379738/

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