Django 的 mod_wsgi 错误:从守护进程读取响应标头时超时

Fli*_*rPA 5 python apache django mod-wsgi python-3.x

我正在运行 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
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

我觉得我错过了一些明显的东西,但看不到它。我在另一个具有相同域下的多个 Django 项目的类似配置中VirtualHost,只要根站点位于最后,就可以正常工作。

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()
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

Fli*_*rPA 0

我发现 - 我们的开发服务器(因为从来没有重建的好时机)是我们唯一的非 Ansiblized 服务器,并且仍然mod_wsgi针对 Python 3.5 构建运行。它virtualenv是针对 Python 3.6 构建的。

virtualenv针对 Python 3.5 重建了它,一切正常。希望这可以避免将来有人烦恼!