Тайм-аут скрипта перед возвратом заголовков: wsgi.py; Django приложение на эласте c бобовый стебель - PullRequest
2 голосов
/ 17 февраля 2020

Я развертываю приложение Django, но в последние 2 дня я случайно начал получать тайм-аут сценария перед возвратом заголовков: wsgy.py со следующими журналами:

[Sun Feb 16 03:02:30.697009 2020] [mpm_prefork:notice] [pid 20719] AH00163: Apache/2.4.41 (Amazon) mod_wsgi/3.5 Python/3.6.8 configured -- resuming normal operations
[Sun Feb 16 03:02:30.697031 2020] [core:notice] [pid 20719] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun Feb 16 03:03:33.906331 2020] [mpm_prefork:notice] [pid 20719] AH00169: caught SIGTERM, shutting down
[Sun Feb 16 03:03:34.352673 2020] [suexec:notice] [pid 29207] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sun Feb 16 03:03:34.368938 2020] [so:warn] [pid 29207] AH01574: module wsgi_module is already loaded, skipping
[Sun Feb 16 03:03:34.371217 2020] [http2:warn] [pid 29207] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Sun Feb 16 03:03:34.371234 2020] [http2:warn] [pid 29207] AH02951: mod_ssl does not seem to be enabled
[Sun Feb 16 03:03:34.371790 2020] [lbmethod_heartbeat:notice] [pid 29207] AH02282: No slotmem from mod_heartmonitor
[Sun Feb 16 03:03:34.371850 2020] [:warn] [pid 29207] mod_wsgi: Compiled for Python/3.6.2.
[Sun Feb 16 03:03:34.371855 2020] [:warn] [pid 29207] mod_wsgi: Runtime using Python/3.6.8.
[Sun Feb 16 03:03:34.374156 2020] [mpm_prefork:notice] [pid 29207] AH00163: Apache/2.4.41 (Amazon) mod_wsgi/3.5 Python/3.6.8 configured -- resuming normal operations
[Sun Feb 16 03:03:34.374172 2020] [core:notice] [pid 29207] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun Feb 16 12:10:08.501006 2020] [core:error] [pid 26171] [client 172.31.3.222:62336] Script timed out before returning headers: wsgi.py

Кажется, это быть похожим на проблему, упомянутую здесь , но эти ответы немного беспорядочные и, кроме того, не решают мою проблему. Вот некоторые дополнительные файлы:

wsgi.py:

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')

application = get_wsgi_application()

Все перечисленные ниже параметры - elasti c beanstalk:

01_packages.config:

packages:
  yum:
    git: []
    postgresql93-devel: []
option_settings:
  "aws:elasticbeanstalk:application:environment":
    DJANGO_SETTINGS_MODULE: "app.settings"
    "PYTHONPATH": "/opt/python/current/app/app:$PYTHONPATH"
    "ALLOWED_HOSTS": ".elasticbeanstalk.com"
  "aws:elasticbeanstalk:container:python":
    WSGIPath: app/wsgi.py
    NumProcesses: 3
    NumThreads: 20
  "aws:elasticbeanstalk:container:python:staticfiles":
    "/static/": "www/static/"

02_ python .config (с пропущенными командами continer_com):

option_settings:
  "aws:elasticbeanstalk:application:environment":
    DJANGO_SETTINGS_MODULE: "app.settings"
    "PYTHONPATH": "/opt/python/current/app/app:$PYTHONPATH"
    "ALLOWED_HOSTS": ".elasticbeanstalk.com"
  "aws:elasticbeanstalk:container:python":
    WSGIPath: app/wsgi.py
    NumProcesses: 3
    NumThreads: 20
  "aws:elasticbeanstalk:container:python:staticfiles":
    "/static/": "www/static/"

03_ apache .config:

container_commands:
  01_setup_apache:
    command: "cp .ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf"
files:
  "/etc/httpd/conf.d/eb_healthcheck.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
        <If "req('User-Agent') == 'ELB-HealthChecker/2.0' && %{REQUEST_URI} == '/'">
            RequestHeader set Host "app.com"
        </If>

app.config:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: app/wsgi.py


files:
  "/etc/httpd/conf.d/wsgi_custom.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
      WSGIApplicationGroup %{GLOBAL}

container_commands:
  01_migrate:
    command: "python manage.py migrate"
    leader_only: true


packages:
  yum:
    git: []
    postgresql93-devel: []

Как видите, я в основном разочаровался, пытаясь найти разные решения без каких-либо реальных решений. Я также, очевидно, не настолько знаком с Apache и elasti c бобовым стеблем и испытывал трудности. Любое руководство будет оценено.

...