Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python gunicorn不在监督下工作(但自行工作)_Python_Linux_Flask_Gunicorn_Supervisord - Fatal编程技术网

Python gunicorn不在监督下工作(但自行工作)

Python gunicorn不在监督下工作(但自行工作),python,linux,flask,gunicorn,supervisord,Python,Linux,Flask,Gunicorn,Supervisord,我在主管的领导下运行gunicorn,没有任何问题,这个周末它停止了工作 当在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 "/

我在主管的领导下运行gunicorn,没有任何问题,这个周末它停止了工作

当在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>
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
如果我在supervisor之外的终端上运行命令:
gunicorn应用程序: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-c/home/azureuser/rz-app/gunicorn.conf.py
,一切正常,但当我这样做时:


sudo su
之后是
/usr/local/bin/gunicorn应用程序: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=-
并发现了困扰我的错误。

注意到这似乎是根用户的问题,当外部主管运行时,我运行:
sudo/usr/local/bin/gunicorn应用程序:application-c/home/azureuser/rz-app/gunicorn.conf.py
,一切正常,但是当我这样做时:
sudo su
后面跟着
/usr/local/bin/gunicorn应用程序:application-c/home/azureuser/rz app/gunicorn.conf.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)