2013-01-22 54 views
1

我跟着this tutorial两次,但在第二台运行它的机器上,我得到了一个监督者运行的gunicorn错误。当我告诉上司启动gunicorn使用:Gunicorn Supervisor启动错误

$ 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.log 

的gunicorn.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: 1239 

而且同样用的virtualenv蟒蛇运行:

$ /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 

这怎么可能是上司发起gunicorn不能当我找到“run_gunicorn”命令可以运行它使用任何python环境,它的工作原理?是的'gunicorn',在INSTALLED_APPS

回答

1

原来,这是一个环境变量,我得到的settings.py不存在supervisord的启动gunicorn下。

此外,被压了下去环境变量错误并没有把它给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执行的应用程序。