Python 如何在supervisord的同一文件中发出杀死gunicorn和运行gunicorn的命令?

Python 如何在supervisord的同一文件中发出杀死gunicorn和运行gunicorn的命令?,python,nginx,flask,gunicorn,supervisord,Python,Nginx,Flask,Gunicorn,Supervisord,我有一个conf文件: [program:nxchill] directory=/home/ubuntu/dev/nxchill command=gunicorn /home/ubuntu/dev/nxchill/nxchill:app -b localhost:5000 autostart=true autorestart=true stderr_logfile=/var/log/nxchill/nxchill.err.log stdout_logfile=/var/log/nxchill/n

我有一个conf文件:

[program:nxchill]
directory=/home/ubuntu/dev/nxchill
command=gunicorn /home/ubuntu/dev/nxchill/nxchill:app -b localhost:5000
autostart=true
autorestart=true
stderr_logfile=/var/log/nxchill/nxchill.err.log
stdout_logfile=/var/log/nxchill/nxchill.out.log
我的目标是首先运行命令:

sudo fuser -k 5000/tcp
停止所有gunicorn进程,然后执行以下命令:

gunicorn /home/ubuntu/dev/nxchill/nxchill:app -b localhost:5000
sudo supervisorctl reread
sudo service supervisor restart
sudo service supervisor restart
因此,当我在conf文件中执行
命令
部分时:

command=sudo fuser -k 5000/tcp gunicorn /home/ubuntu/dev/nxchill/nxchill:app -b localhost:5000
运行以下命令:

gunicorn /home/ubuntu/dev/nxchill/nxchill:app -b localhost:5000
sudo supervisorctl reread
sudo service supervisor restart
sudo service supervisor restart
nxchill致命性退出过快(进程 日志(可能有详细信息)

记录如下:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 129, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 138, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 350, in import_app
    __import__(module)
ImportError: Import by filename is not supported.
[2018-06-04 07:59:33 +0000] [1527] [INFO] Worker exiting (pid: 1527)
[2018-06-04 07:59:33 +0000] [1523] [INFO] Shutting down: Master
[2018-06-04 07:59:33 +0000] [1523] [INFO] Reason: Worker failed to boot.

现在,即使只有一个命令存在,也会出现相同的错误。

解决方案是忽略命令
sudo fuser-k 5000/tcp
,直接运行
gunicorn
命令

该命令应启动服务器,以便flask应用程序在系统重新启动时永远不会关闭,等等

尽管如此,由于没有执行杀死端口的命令,将使用越来越多的端口。这可以由cron作业每天或每周运行一次。不必担心此命令会杀死flask应用程序,因为它将由supervisord恢复