mod_wsgi Django 错误:从守护进程读取响应时超时 headers
mod_wsgi error with Django: Timeout when reading response headers from daemon process
我 运行宁 Django 2.0.4 与 mod_wsgi 4.5.20.
当我尝试将站点部署到我们位于 /parature
的开发环境时出现错误。奇怪的是,部署在 VirtualHost
根目录下的站点正常响应:
[Tue Apr 10 13:34:08.998704 2018] [wsgi:error] [pid 65245] [client xx.yy.zz:65390] Timeout when reading response headers from daemon process 'parature-develop-https': /var/django/html/parature-develop/config/wsgi.py
我可以通过 runserver
运行 站点并激活 virtualenv
。它不应该超时,因为我只是想调出 Django 管理站点。
<VirtualHost *:443>
SSLEngine On
ServerName wrds-pub1-dev.example.com
ErrorLog "|/usr/sbin/cronolog /var/log/httpd/errorlog/%Y/%Y-%m-wrds-pub1-dev-error.log"
LogLevel info
WSGIApplicationGroup %{GLOBAL}
# The site I'm adding, which isn't working
WSGIDaemonProcess parature-develop-https python-home=/var/django/virtualenvs/parature-develop request-timeout=600
WSGIProcessGroup parature-develop-https
WSGIScriptAlias /parature /var/django/html/parature-develop/config/wsgi.py process-group=parature-develop-https
<Directory /var/django/html/parature-develop/config>
Require all granted
</Directory>
Alias /parature/static/ /var/django/html/parature-develop/static/
<Directory /var/django/html/parature-develop/static>
Require all granted
</Directory>
# The site which has been and continues to work
WSGIDaemonProcess django-wrds-dev-https python-home=/var/django/virtualenvs/django-wrds-dev request-timeout=600
WSGIScriptAlias / /var/django/html/django-wrds-dev/config/wsgi.py process-group=django-wrds-dev-https
<Directory /var/django/html/django-wrds-dev/config>
Require all granted
</Directory>
Alias /static/ /var/django/html/django-wrds-dev/static/
<Directory /var/django/html/django-wrds-dev/static>
Require all granted
</Directory>
Alias /media/ /var/media/wrds-www/
<Directory /var/media/wrds-www>
Require all granted
</Directory>
</VirtualHost>
我觉得我错过了一些明显的东西,但看不到它。我在另一个 VirtualHost
中有一个类似的配置,在同一个域下有多个 Django 项目,并且工作正常,只要根站点排在最后。
wsgi.py
几乎与正在运行的站点完全相同:
import os, sys, logging
from socket import gethostname
from django.core.wsgi import get_wsgi_application
# Since this powers Apache, let's route Python errors to the Apache
# log rather than STDOUT, where they'll never be seen.
logging.basicConfig(stream=sys.stderr)
# Figure out where we're at, and add the parent to the path
sys.path.append(os.sep.join(os.path.abspath(__file__).split(os.sep)[:-2]))
# wrds-pub1-dev server
if 'wrds-pub1-dev' in gethostname():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
# wrds-pub* production servers.
elif 'wrds-pub' in gethostname():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
# else use dev settings.
else:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
application = get_wsgi_application()
有什么想法吗?
我想通了 - 我们的开发服务器(因为从来没有重建的好时机)是我们唯一的 non-Ansiblized 服务器,并且仍然 运行 mod_wsgi
是针对 Python 3.5。 virtualenv
是针对 Python 3.6.
构建的
我针对 Python 3.5 重建了 virtualenv
,一切正常。希望这会在将来拯救某人 hair-pulling!
我 运行宁 Django 2.0.4 与 mod_wsgi 4.5.20.
当我尝试将站点部署到我们位于 /parature
的开发环境时出现错误。奇怪的是,部署在 VirtualHost
根目录下的站点正常响应:
[Tue Apr 10 13:34:08.998704 2018] [wsgi:error] [pid 65245] [client xx.yy.zz:65390] Timeout when reading response headers from daemon process 'parature-develop-https': /var/django/html/parature-develop/config/wsgi.py
我可以通过 runserver
运行 站点并激活 virtualenv
。它不应该超时,因为我只是想调出 Django 管理站点。
<VirtualHost *:443>
SSLEngine On
ServerName wrds-pub1-dev.example.com
ErrorLog "|/usr/sbin/cronolog /var/log/httpd/errorlog/%Y/%Y-%m-wrds-pub1-dev-error.log"
LogLevel info
WSGIApplicationGroup %{GLOBAL}
# The site I'm adding, which isn't working
WSGIDaemonProcess parature-develop-https python-home=/var/django/virtualenvs/parature-develop request-timeout=600
WSGIProcessGroup parature-develop-https
WSGIScriptAlias /parature /var/django/html/parature-develop/config/wsgi.py process-group=parature-develop-https
<Directory /var/django/html/parature-develop/config>
Require all granted
</Directory>
Alias /parature/static/ /var/django/html/parature-develop/static/
<Directory /var/django/html/parature-develop/static>
Require all granted
</Directory>
# The site which has been and continues to work
WSGIDaemonProcess django-wrds-dev-https python-home=/var/django/virtualenvs/django-wrds-dev request-timeout=600
WSGIScriptAlias / /var/django/html/django-wrds-dev/config/wsgi.py process-group=django-wrds-dev-https
<Directory /var/django/html/django-wrds-dev/config>
Require all granted
</Directory>
Alias /static/ /var/django/html/django-wrds-dev/static/
<Directory /var/django/html/django-wrds-dev/static>
Require all granted
</Directory>
Alias /media/ /var/media/wrds-www/
<Directory /var/media/wrds-www>
Require all granted
</Directory>
</VirtualHost>
我觉得我错过了一些明显的东西,但看不到它。我在另一个 VirtualHost
中有一个类似的配置,在同一个域下有多个 Django 项目,并且工作正常,只要根站点排在最后。
wsgi.py
几乎与正在运行的站点完全相同:
import os, sys, logging
from socket import gethostname
from django.core.wsgi import get_wsgi_application
# Since this powers Apache, let's route Python errors to the Apache
# log rather than STDOUT, where they'll never be seen.
logging.basicConfig(stream=sys.stderr)
# Figure out where we're at, and add the parent to the path
sys.path.append(os.sep.join(os.path.abspath(__file__).split(os.sep)[:-2]))
# wrds-pub1-dev server
if 'wrds-pub1-dev' in gethostname():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
# wrds-pub* production servers.
elif 'wrds-pub' in gethostname():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
# else use dev settings.
else:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
application = get_wsgi_application()
有什么想法吗?
我想通了 - 我们的开发服务器(因为从来没有重建的好时机)是我们唯一的 non-Ansiblized 服务器,并且仍然 运行 mod_wsgi
是针对 Python 3.5。 virtualenv
是针对 Python 3.6.
我针对 Python 3.5 重建了 virtualenv
,一切正常。希望这会在将来拯救某人 hair-pulling!