Supervisord,Gunicorn(退出状态127;不预期)

时间:2016-05-31 23:01:45

标签: django executable gunicorn supervisord supervisor

我希望使用主管来监控和运行一个gunicorn服务器。

当我跑步时:

/usr/bin/gunicorn app.wsgi:application -c config.conf

它有效。

但是我的主管conf文件中完全相同的命令不起作用。任何解释?

supervisor.conf

[supervisord]
[group:app]
programs=gunicorn_app
[program:gunicorn_app]
environment=PYTHONPATH=usr/bin
command=/usr/bin/gunicorn app.wsgi:application -c gunicorn.conf.py
directory=~/path/to/app

autostart=true
autorestart=true

environment=LANG="en_US.UTF-8",LC_ALL="en_US.UTF-8",LC_LANG="en_US.UTF-8"

我收到这样的错误:

2016-05-31 22:53:34,786 INFO spawned: 'gunicorn_app' with pid 18763
2016-05-31 22:53:34,789 INFO exited: gunicorn_app (exit status 127; not expected)
2016-05-31 22:53:35,791 INFO spawned: 'gunicorn_app' with pid 18764
2016-05-31 22:53:35,795 INFO exited: gunicorn_app (exit status 127; not expected)
2016-05-31 22:53:37,798 INFO spawned: 'gunicorn_app' with pid 18765
2016-05-31 22:53:37,802 INFO exited: gunicorn_app (exit status 127; not expected)
2016-05-31 22:53:40,807 INFO spawned: 'gunicorn_app' with pid 18766
2016-05-31 22:53:40,810 INFO exited: gunicorn_app (exit status 127; not expected)

我知道退出代码127表示“找不到命令”但我可以在命令行上执行完全相同的命令。

2 个答案:

答案 0 :(得分:4)

尝试使用绝对路径。 /家庭/路径/到/应用 不是〜/ path / to / app

答案 1 :(得分:2)

正如您正确地说的那样,该代码表示​​“找不到命令”,可能是由于以下原因之一造成的:

  1. 主管无法找到配置文件
  2. 错误的配置

无论如何,我都会推荐您:

情况1:

确保为您提供gunicorn.conf.py文件的绝对路径(完整路径)(例如/home/user/path/to/gunicorn.conf.py)

情况2:

重新访问您的超级用户配置文件,并尝试确定可能在哪里出现错误。最好的方法是找到日志文件并打开它以确认原因。为方便起见,建议将以下内容添加到您的supervisord.conf文件中:

[program:gunicorn]
# where the configuation file is located on the /home/<user>/path/to/configuration_file
command=/usr/local/bin/gunicorn app.wsgi:application -c /home/<user>/path/to/gunicorn.conf.py  
directory=~/path/to/app
autostart=true
autorestart=true

#add this setting to log error
stderr_logfile=/var/log/gunicorn.err.log
stdout_logfile=/var/log/gunicorn.out.log

environment=LANG="en_US.UTF-8",LC_ALL="en_US.UTF-8",LC_LANG="en_US.UTF-8"

注意:我在这里所做的假设是您想使用gunicorn部署或运行​​Django应用程序。午餐时遇到任何错误,都可以在gunicorn.err.log文件中进行验证。

相关问题