mod_wsgi error with Django: Timeout when reading response headers from daemon process

家住魔仙堡 提交于 2019-12-07 18:23:37

问题


I'm running Django 2.0.4 with mod_wsgi 4.5.20.

I'm getting an error when I try to deploy a site to our dev environment at /parature. What's weird is that the site deployed at the root of the VirtualHost is responding as normal:

[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

I can run the site via runserver with the virtualenv activated. It shouldn't be timing out, as I'm just trying to bring up the Django admin site.

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

I feel like I'm missing something obvious, but can't see it. I've got a similar configuration in another VirtualHost with multiple Django projects under the same domain, and that is working fine, as long as the root site comes last.

The wsgi.py is almost exactly the same as the site that is working as well:

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()

Any ideas?


回答1:


I figured it out - our dev server (since there's never a good time for a rebuild) is our only non-Ansiblized server, and still running mod_wsgi built against Python 3.5. The virtualenv was built against Python 3.6.

I rebuilt the virtualenv against Python 3.5, and everything works. Hopefully this saves someone hair-pulling in the future!



来源:https://stackoverflow.com/questions/49760253/mod-wsgi-error-with-django-timeout-when-reading-response-headers-from-daemon-pr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!