5

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

0

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!

Sign up to request clarification or add additional context in comments.

2 Comments

Hi there, I'm in a similar situation right now. I've installed mod_wsgi using pip install mod_wsgi in my virtualenv, there by ensuring that both use the same python version. yet my requests are getting timed out and I get an error exactly like you were getting.
Are you sure that Apache is pointing to the mod_wsgi.so that gets built inside the virtualenv of your project? Or that you've moved the compiled .so file somewhere central?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.