python - Django : Timeout when reading response headers from daemon process 的 mod_wsgi 错误

标签 python django python-3.x apache mod-wsgi

我正在使用 mod_wsgi 4.5.20 运行 Django 2.0.4。

当我尝试将站点部署到位于 /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

我可以通过激活 virtualenvrunserver 运行站点。它不应该超时,因为我只是想调出 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()

有什么想法吗?

最佳答案

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

我针对 Python 3.5 重建了 virtualenv,一切正常。希望这可以避免将来有人抓头发!

关于python - Django : Timeout when reading response headers from daemon process 的 mod_wsgi 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49760253/

相关文章:

python - 创建具有 'class' 属性的元素会引发语法错误

python - 将 urllib.request 转换为整数

python - 如何覆盖 python 中的对象?

python - 使用 Python3 在 Pyramid 中使用 Websocket

python-3.x - 计算旋转矩形区域中的非零像素数

python - Pandas 如何在特定日期和日期范围内的总和值之间重新采样?

python - 通过 sendgrid-python API lib 将 django 对象上下文传递给 sendgrid 电子邮件

python - 如何从使用 Django 中主要形式的 pk 的管理员内联自定义字段的查询集?

django - 在 Django 应用程序中多次访问静态数据

python - 在不带参数的函数中调用函数