Gunicorn + Django +主管 - 主管无法启动Gunicorn:ENOENT

时间:2016-09-26 19:10:21

标签: django virtualenv gunicorn supervisor enoent

**检查堆叠溢出的所有事情**

我使用gunicorn和nginx部署了Django。 django项目位于虚拟环境中。我跑的时候一切都很完美 -

  

gunicorn mydjangoproject.wsgi -c gunicorn_config.py

我在包含manage.py的Django项目文件夹中运行上面的命令,虚拟环境处于活动状态。

但是现在我想关闭服务器终端并希望gunicorn自动运行。为此,我使用主管。我使用apt-get安装了supervisor,并在supervisor的conf.d中创建了一个gunicorn.conf文件。

但是当我运行supervisorctl start gunicorn时,我得到一个致命的错误 -
    gunicorn:ERROR(异常终止)

所以检查了日志文件,然后说 -

主管:无法执行root / ervirtualenvpy2 / bin / gunicorn:ENOENT
没有生成子进程

我对supervisor的gunicorn.conf的配置文件看起来像这样 -

[program:gunicorn]
command = root/ervirtualenvpy2/bin/gunicorn myproject.wsgi -c     root/path/to/the/gunicorn_conf.py/file
directory = root/ervirtualenvpy2/path/to/myproject/
user=root
autorestart=true

2 个答案:

答案 0 :(得分:2)

按照你所说的和你的配置一切似乎都是正确的,除了你指定了相对路径而不是绝对路径:

见gunicorn docs

相反它应该是:

[program:gunicorn]
command = /root/ervirtualenvpy2/bin/gunicorn myproject.wsgi -c /root/path/to/the/gunicorn_conf.py/file
directory = /root/ervirtualenvpy2/path/to/myproject
user=root
autorestart=true

答案 1 :(得分:0)

还要检查 env/bin/gunicorn 文件中的 gunicorn 文件路径

就我而言,我将 env 目录更改为其他位置,因此请确保 错误的路径:#!/home/ubuntu/nikhil_project/env/bin/python 正确路径:#!/home/ubuntu/env/bin/python