gunicorn错误(exception终止)

即时通讯运行的结构脚本,其中包括,应该重新启动在Ubuntu服务器gunicorn,命令如下:

supervisorctl status projectname:gunicorn | sed "s/.*[pid ]\([0-9]\+\)\,.*/\1/" | xargs kill -HUP 

问题是,gunicorn似乎并没有运行在第一个地方,所以过程不能被杀死,我ssh'd进入亚马逊ec2实例,跑

 sudo supervisorctl restart projectname:gunicorn' 

我得到一个错误回应,说:

项目名称:gunicorn:错误(未运行)项目名称:gunicorn错误(exception终止)

所以我试图通过运行启动gunicorn

 sudo supervisorctl start projectname:gunicorn 

和错误说

'项目名称:gunicorn:错误(exception终止)'

所以我需要运行gunicorn,并且即时遇到麻烦

我也检查了gunicorn日志和下面的文字,下面是相关的输出

 2014-01-17 14:58:14 [12260] [INFO] Starting gunicorn 0.14.3 2014-01-17 14:58:14 [12260] [INFO] Listening at: http://127.0.0.1:9000 (12260) 2014-01-17 14:58:14 [12260] [INFO] Using worker: sync 2014-01-17 14:58:14 [12263] [INFO] Booting worker with pid: 12263 2014-01-17 14:58:14 [12264] [INFO] Booting worker with pid: 12264 2014-01-17 14:58:14 [12265] [INFO] Booting worker with pid: 12265 2014-01-17 14:58:14 [12266] [INFO] Booting worker with pid: 12266 2014-01-17 14:58:14 [12263] [INFO] Worker exiting (pid: 12263) 2014-01-17 14:58:14 [12264] [INFO] Worker exiting (pid: 12264) 2014-01-17 14:58:14 [12265] [INFO] Worker exiting (pid: 12265) 2014-01-17 14:58:14 [12266] [INFO] Worker exiting (pid: 12266) Traceback (most recent call last): File "/opt/screening/env/bin/gunicorn_django", line 9, in <module> load_entry_point('gunicorn==0.14.3', 'console_scripts', 'gunicorn_django')() File "/opt/compliance_engine/env/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 129, in run DjangoApplication("%prog [OPTIONS] [SETTINGS_PATH]").run() File "/opt/compliance_engine/env/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 129, in run Arbiter(self).run() File "/opt/compliance_engine/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 184, in run self.halt(reason=inst.reason, exit_status=inst.exit_status) File "/opt/compliance_engine/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 279, in halt self.stop() File "/opt/compliance_engine/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 327, in stop self.reap_workers() File "/opt/compliance_engine/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 413, in reap_workers raise HaltServer(reason, self.WORKER_BOOT_ERROR) gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3> 

另外,这里是conf文件

 [program:gunicorn] command=/opt/screening/env/bin/gunicorn_django --pythonpath . ce.settings -w 4 --bind 127.0.0.1:9000 directory=/opt/screening/repository user=www-data autostart=true autorestart=true stdout_logfile=/opt/screening/logs/gunicorn.log redirect_stderr=true [program:celeryd] command=/opt/screening/env/bin/python manage.py celeryd --autoscale=16,2 -E -l INFO --pidfile=/opt/screening/tmp/pids/celeryd.pid directory=/opt/screening/repository user=www-data autostart=true autorestart=true stdout_logfile=/opt/screening/logs/celeryd.log redirect_stderr=true [program:celerybeat] command=/opt/screening/env/bin/python manage.py celerybeat -l INFO -- schedule=/opt/screening/tmp/celerybeat-schedule -- pidfile=/opt/screening/tmp/pids/celerybeat.pid directory=/opt/screening/repository user=www-data autostart=true autorestart=true stdout_logfile=/opt/screening/logs/celerybeat.log redirect_stderr=true [program:celerycam] command=/opt/screening/env/bin/python manage.py celerycam -- pidfile=/opt/screening/tmp/pids/celerycam.pid directory=/opt/screening/repository user=www-data autostart=true autorestart=true stdout_logfile=/opt/screening/logs/celerycam.log redirect_stderr=true [group:screening] programs=gunicorn,celeryd,celerybeat,celerycam 

有任何想法吗? 我明白,这是很多文字,任何提示或指针将不胜感激

谢谢阅读,

编辑:

独立运行独angular兽,启动虚拟env并跑

 python manage.py run_gunicorn 

terminal打印下面的输出

 2014-01-19 22:02:35 [14735] [INFO] Starting gunicorn 0.14.3 2014-01-19 22:02:35 [14735] [INFO] Listening at: http://127.0.0.1:8000 (14735) 2014-01-19 22:02:35 [14735] [INFO] Using worker: sync 2014-01-19 22:02:35 [14742] [INFO] Booting worker with pid: 14742 

还在virtualenv中运行了运行服务器:

 python manage.py runserver 7000 Validating models... 0 errors found Django version 1.3, using settings 'ce.settings' Development server is running at http://127.0.0.1:7000/ Quit the server with CONTROL-C. 

所以没有明显的错误

编辑2:

已经和其他一些人谈过这个问题,并被build议查看gunicorn日志的权限,这里是:

 -rw-rw-r-- 1 www-data ubuntu 3270504 2014-01-19 23:23 gunicorn.log 

www-data用户匹配pipe理员configuration中设置的用户

编辑3:我再次运行gunicorn命令,但是这次添加了日志信息:

 gunicorn_django --pythonpath . ce.settings -w 4 --bind 127.0.0.1:9000 --debug --log-level debug 

并收到以下错误信息:

 Traceback (most recent call last): File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 453, in spawn_worker worker.init_process() File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 99, in init_process self.wsgi = self.app.wsgi() File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 101, in wsgi self.callable = self.load() File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 87, in load mod = util.import_module("gunicorn.app.django_wsgi") File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 18, in <module> from django.core.management.validation import get_validation_errors File "/opt/screening/env/local/lib/python2.7/site-packages/django/core/management/validation.py", line 3, in <module> from django.contrib.contenttypes.generic import GenericForeignKey, GenericRelation File "/opt/screening/env/local/lib/python2.7/site-packages/django/contrib/contenttypes/generic.py", line 6, in <module> from django.db import connection File "/opt/screening/env/local/lib/python2.7/site-packages/django/db/__init__.py", line 14, in <module> if not settings.DATABASES: File "/opt/screening/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 276, in __getattr__ self._setup() File "/opt/screening/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup self._wrapped = Settings(settings_module) File "/opt/screening/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 89, in __init__ raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings 'ce.settings' (Is it on sys.path?): No module named ce.settings 2014-01-20 09:14:22 [31830] [INFO] Worker exiting (pid: 31830) Traceback (most recent call last): File "/opt/screening/env/bin/gunicorn_django", line 9, in <module> load_entry_point('gunicorn==0.14.3', 'console_scripts', 'gunicorn_django')() File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 129, in run DjangoApplication("%prog [OPTIONS] [SETTINGS_PATH]").run() File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 129, in run Arbiter(self).run() File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 184, in run self.halt(reason=inst.reason, exit_status=inst.exit_status) File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 279, in halt self.stop() File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 327, in stop self.reap_workers() File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 413, in reap_workers raise HaltServer(reason, self.WORKER_BOOT_ERROR) gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3> 

所以看来突出的信息是这样的:

 ImportError: Could not import settings 'ce.settings' (Is it on sys.path?): No module named ce.settings 

我的设置是在一个设置目录,并存在init文件,所以问题是没有。 此外,应用程序在runserver上启动,因此设置文件必须是可导入的

Solutions Collecting From Web of "gunicorn错误(exception终止)"

(这个问题是由OP在一个问题编辑中回答的,转换成了一个社区维基答案,看问题没有答案,但问题解决了(或者在聊天中扩展了) )

该OP写道:

解决了这个问题(我认为)

根据这个链接中的信息https://stackoverflow.com/a/19256794/2049067 ,我将项目添加到Python路径

 export PYTHONPATH=:/my/path 

然后再次运行gunicorn命令:

 gunicorn_django --pythonpath . ce.settings -w 4 --bind 127.0.0.1:9000 --debug --log-level debug 

并且gunicorn正在运行,并且该站点是可访问的,我退出了ssh,一切都(似乎)仍在工作。 我还应该补充说,在我设置pythonpath之前,我改变了gunicorn日志上的ownerwhip:

 sudo chown -R www-data:www-data gunicorn.log 

虽然我不知道这是否有帮助

看看应用程序已经运行多年,我不知道如何从pythonpath中删除项目