基本hello.wsgi
运行正常。其他django应用程序完美与绝对相同的virtualenv版本。
mod_wsgi
挂起约10分钟(!!!),我发现没有什么可以指出我的问题(loglevel debug):
[Tue Mar 25 23:11:08.878578 2014] [:info] [pid 4719:tid 140720591648640] mod_wsgi (pid=4719): Attach interpreter ''.
[Tue Mar 25 23:11:08.879171 2014] [:info] [pid 4717:tid 140720591648640] mod_wsgi (pid=4717): Attach interpreter ''.
[Tue Mar 25 23:11:10.891348 2014] [authz_core:debug] [pid 4730:tid 140720477226752] mod_authz_core.c(802): [client 127.0.0.1:40844] AH01626: authorization result of Require all granted: granted
[Tue Mar 25 23:11:10.891391 2014] [authz_core:debug] [pid 4730:tid 140720477226752] mod_authz_core.c(802): [client 127.0.0.1:40844] AH01626: authorization result of <RequireAny>: granted
[Tue Mar 25 23:11:10.891489 2014] [authz_core:debug] [pid 4730:tid 140720477226752] mod_authz_core.c(802): [client 127.0.0.1:40844] AH01626: authorization result of Require all granted: granted
[Tue Mar 25 23:11:10.891497 2014] [authz_core:debug] [pid 4730:tid 140720477226752] mod_authz_core.c(802): [client 127.0.0.1:40844] AH01626: authorization result of <RequireAny>: granted
[Tue Mar 25 23:11:10.903921 2014] [:info] [pid 4719:tid 140720469034752] mod_wsgi (pid=4719): Create interpreter 'prj-dev|'.
[Tue Mar 25 23:11:10.905378 2014] [:info] [pid 4719:tid 140720469034752] [remote 127.0.0.1:57616] mod_wsgi (pid=4719, process='prj.project-dev', application='prj-dev|'): Loading WSGI script '/var/www/prj.project-dev/venv/www/public/index.wsgi'.
[Tue Mar 25 23:11:12.014799 2014] [:error] [pid 4719:tid 140720469034752] /usr/lib/python2.7/dist-packages/numpy/oldnumeric/__init__.py:11: ModuleDeprecationWarning: The oldnumeric module will be dropped in Numpy 1.9
[Tue Mar 25 23:11:12.014843 2014] [:error] [pid 4719:tid 140720469034752] warnings.warn(_msg, ModuleDeprecationWarning)
[Tue Mar 25 23:11:12.014846 2014] [:error] [pid 4719:tid 140720469034752]
[Tue Mar 25 23:16:11.888631 2014] [:info] [pid 4719:tid 140720485820160] mod_wsgi (pid=4719): Daemon process deadlock timer expired, stopping process 'prj.project-dev'.
[Tue Mar 25 23:16:11.888761 2014] [:info] [pid 4719:tid 140720591648640] mod_wsgi (pid=4719): Shutdown requested 'prj.project-dev'.
[Tue Mar 25 23:16:16.889065 2014] [:info] [pid 4719:tid 140720121513728] mod_wsgi (pid=4719): Aborting process 'prj.project-dev'.
[Tue Mar 25 23:16:16.895499 2014] [core:error] [pid 4730:tid 140720477226752] [client 127.0.0.1:40844] End of script output before headers: index.wsgi
[Tue Mar 25 23:16:17.160980 2014] [:info] [pid 5295:tid 140720591648640] mod_wsgi (pid=5295): Attach interpreter ''.
Apache配置也没有任何有趣的内容。相同的配置适用于其他服务器。
<VirtualHost *:80>
ServerName prj-dev
ServerAdmin admin@force.fm
DocumentRoot "/var/www/prj.project-dev/venv/www/public"
ErrorLog /var/log/apache2/prj.project-dev/error_log
CustomLog /var/log/apache2/prj.project-dev/access_log common
Alias /media/ /var/www/prj.project-dev/venv/prj/prj/media/
Alias /static/ /var/www/prj.project-dev/venv/prj/prj/static/
Alias /usermedia/ /var/www/prj.project-dev/venv/prj/prj/usermedia/
<Directory /var/www/prj.project-dev/venv/prj/prj/usermedia>
Order deny,allow
Allow from all
</Directory>
<Directory /var/www/prj.project-dev/venv/prj/prj/media>
Order deny,allow
Allow from all
</Directory>
<Directory /var/www/prj.project-dev/venv/prj/prj/static>
Order deny,allow
Allow from all
</Directory>
WSGIDaemonProcess prj.project-dev user=user group=user processes=2 threads=2 display-name=%{GROUP}
WSGIProcessGroup prj.project-dev
WSGIScriptAlias / /var/www/prj.project-dev/venv/www/public/index.wsgi
XSendFile on
<Directory /var/www/prj.project-dev/venv/www/public>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
wsgi
:
import os, sys
activate_this = '/var/www/prj.project-dev/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
sys.path = [
'/var/www/prj.project-dev/venv/lib/python2.7/site-packages/',
'/var/www/prj.project-dev/venv/prj/',
'/var/www/prj.project-dev/venv/',
] + sys.path
os.environ['DJANGO_SETTINGS_MODULE'] = 'prj.settings'
import django.core.handlers.wsgi
#from raven.contrib.django.middleware.wsgi import Sentry
application = django.core.handlers.wsgi.WSGIHandler()
#application = Sentry(django.core.handlers.wsgi.WSGIHandler())
我的问题是:我怎样才能找到它挂起的真正原因?
答案 0 :(得分:12)
mod_wsgi文档涵盖了这一点。
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Python_Simplified_GIL_State_API
简而言之,您可能正在使用Python扩展模块,该模块未实现在Python子解释器中正常工作。在执行阻塞操作时,该扩展模块或扩展模块未正确释放GIL。两者都可能导致解释器死锁。
使用文档中的解决方案,看看是否有帮助。
答案 1 :(得分:3)
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
ServerAdmin raghav@xyz.com
<Directory /var/www/mysite/mysite>
AddHandler wsgi-script .py
Options +ExecCGI
</Directory>
DocumentRoot /var/www/mysite
WSGIDaemonProcess myproject python-path=/var/www/mysite:/var/www/environ/lib/python2.7/site-packages
#WSGIProcessGroup mysite
WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
WSGIApplicationGroup %{GLOBAL}
<Directory /var/www/mysite/mysite/>
order deny,allow
Allow from all
</Directory>
我也遇到了同样的错误,我使用此配置解决了这个问题。
同时将以下行添加到/etc/apache2/apache.config
#WSGIPythonPath /var/www/mysite
答案 2 :(得分:2)
我知道这个帖子已经三年了,但是当我遇到类似的问题时,我偶然发现了它,所以我想我会添加我的解决方案。在我的情况下,虚拟环境中的某些东西需要在Apache中启用mod_ssl,即使这些站点都没有使用SSL(他们这样做但是它在其他地方终止)。所以
a2enmod ssl
service apache2 restart
修正了它。
答案 3 :(得分:1)
在深入了解上述答案之后。我必须将进程数从5设置为1.还使用多工作程序mpm。
LoadModule mpm_worker_module modules/mod_mpm_worker.so
WSGIDaemonProcess music user=apache group=apache processes=1 threads=30 python-path=/srv/www/music/service/venv/lib/python2.7/site-packages