I am deploying a Django app, but in the past 2 days I randomly started receiving the Script timed out before returning headers: wsgy.py with the following logs:
[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
This seems to be similar to the problem mentioned here, but those answers are a bit of a mess and additionally do not solve my problem. Here are some additional files:
wsgi.py:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
application = get_wsgi_application()
All of the following are elastic beanstalk configs:
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 (with continer_commands ommitted):
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: []
As you can see I have basically grown frustrated attempting different solutions with no real fix. I am also obviously not that familiar with Apache and elastic beanstalk and have had difficulty. Any guidance would be appreciated.