我已经跟踪了this tutorial两次,但是在我运行它的第二台机器上,我得到了一个supervisor运行的gunicorn错误。当我告诉主管使用以下命令启动gunicorn时:
$ sudo supervisorctl start gunicorn
gunicorn: ERROR (abnormal termination)gunicorn_err.log会重复此操作:
Unknown command: 'run_gunicorn'
Type 'manage.py help' for usage.主控引擎配置如下所示:
[program:gunicorn]
command=/home/ubuntu/.virtualenvs/<VIRTUALENV>/bin/python /home/ubuntu/<APPNAME>/manage.py run_gunicorn -w 4 -k gevent
directory=/home/ubuntu/<APPNAME>
user=www-data
autostart=true
autorestart=true
stdout_logfile = /var/log/supervisor/gunicorn.log
stderr_logfile = /var/log/supervisor/gunicorn_err.loggunicorn.log为空。我已经尝试将用户切换到ubuntu并在没有virtualenv的情况下运行(我的默认python环境也已准备就绪,因为其中包含所有必备的软件包)。实际上,如果我手动运行以下命令,我甚至尝试删除gunicorn.conf中变量赋值之间的空格:
$ /usr/bin/python /home/ubuntu/<APPNAME>/manage.py run_gunicorn -w 4 -k gevent
2013-01-22 19:20:33 [1231] [INFO] Starting gunicorn 0.17.2
2013-01-22 19:20:33 [1231] [INFO] Listening at: http://127.0.0.1:8000 (1231)
2013-01-22 19:20:33 [1231] [INFO] Using worker: gevent
2013-01-22 19:20:33 [1236] [INFO] Booting worker with pid: 1236
2013-01-22 19:20:33 [1237] [INFO] Booting worker with pid: 1237
2013-01-22 19:20:33 [1238] [INFO] Booting worker with pid: 1238
2013-01-22 19:20:33 [1239] [INFO] Booting worker with pid: 1239virtualenv python运行也是如此:
$ /home/ubuntu/.virtualenvs/<VIRTUALENV>/bin/python /home/ubuntu/<APPNAME>/manage.py run_gunicorn -w 4 -k gevent
2013-01-22 19:21:53 [1246] [INFO] Starting gunicorn 0.17.2
2013-01-22 19:21:53 [1246] [INFO] Listening at: http://127.0.0.1:8000 (1246)
2013-01-22 19:21:53 [1246] [INFO] Using worker: gevent
2013-01-22 19:21:53 [1251] [INFO] Booting worker with pid: 1251
2013-01-22 19:21:53 [1252] [INFO] Booting worker with pid: 1252
2013-01-22 19:21:53 [1253] [INFO] Booting worker with pid: 1253
2013-01-22 19:21:53 [1254] [INFO] Booting worker with pid: 1254当我可以使用任何python环境运行'run_gunicorn‘命令并且它工作时,主管启动的gunicorn怎么可能找不到它?是的,'gunicorn',在INSTALLED_APPS中
发布于 2013-01-23 03:05:48
事实证明,这是我在settings.py中得到的一个环境变量,在supervisord的start gunicorn下是不存在的。
此外,环境变量error被抑制,并且从未进入gunicorn_err.log
当我将gunicorn.conf命令切换为:
command = /usr/local/bin/gunicorn_django -w 4 -k gevent我可以在gunicorn_err.log中看到一个更清晰的错误
raise KeyError(key)
KeyError: 'AWS_STORAGE_BUCKET_NAME'
2013-01-22 22:51:09 [2290] [INFO] Worker exiting (pid: 2290)为了解决这个问题,我只是没有使用环境变量,而是使用了不同的方法来获取变量。它起作用了,然后我恢复到原来的virtualenv run_gunicorn命令
command=/home/ubuntu/.virtualenvs/<VIRTUALENV>/bin/python /home/ubuntu/<APPNAME>/manage.py run_gunicorn -w 4 -k gevent如果继续在设置中使用环境变量很重要,请查看supervisord-configuration似乎有一种方法可以为supervisord执行的应用程序配置键/值环境变量对。
https://stackoverflow.com/questions/14464533
复制相似问题