我在主管的监督下没有任何问题,本周末它停止了工作。
在supervisorctl中进行application start
时,这是在应用程序日志中:
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
事情按预期工作。
这是一个烧瓶应用程序,这里是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
它无法正常工作
答案 0 :(得分:0)
发现问题,它与gunicorn或supervisor无关,我的应用程序有一个仅在用户下载的依赖项,我注意到当我在命令之前sudo su
时出现同样的问题,所以我记录了root /usr/local/bin/gunicorn --log-file=- application:application -c /home/azureuser/rz-app/gunicorn.conf.py
时发生的事情,添加了--log-file=-
并发现了困扰我的错误。