【问题标题】:How do I give command for killing gunicorn and running gunicorn in the same file of supervisord?如何在 supervisord 的同一个文件中发出杀死 gunicorn 和运行 gunicorn 的命令?
【发布时间】:2018-11-13 12:19:29
【问题描述】:

我有一个 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

所以,当我在 conf 文件中创建 command 部分时:

command=sudo fuser -k 5000/tcp gunicorn /home/ubuntu/dev/nxchill/nxchill:app -b localhost:5000

运行以下命令:

sudo supervisorctl reread
sudo service supervisor restart
sudo service supervisor restart

nxchill FATAL 退出太快(进程 日志可能有详细信息)

日志是:

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.

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

【问题讨论】:

    标签: python nginx flask gunicorn supervisord


    【解决方案1】:

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

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

    虽然,越来越多的端口将被使用,因为杀死它们的命令没有被执行。这可以由 cron 作业在一天或一周内运行一次。不必担心这个命令会杀死烧瓶应用程序,因为它将由 supervisord 恢复。

    【讨论】:

      猜你喜欢
      • 2022-01-14
      • 2022-08-04
      • 2021-10-06
      • 1970-01-01
      • 2017-01-13
      • 2020-07-20
      • 1970-01-01
      • 2020-09-03
      • 1970-01-01
      相关资源
      最近更新 更多