脚本在返回标头之前超时:弹性 beantalk 上的 wsgi.py [英] Script timed out before returning headers: wsgi.py on elastic beanstalk

查看:34
本文介绍了脚本在返回标头之前超时:弹性 beantalk 上的 wsgi.py的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Django 应用程序部署到 Elastic Beanstalk.当我访问该页面时,它永远不会加载.日志说:

I'm trying to deploy a Django application to Elastic Beanstalk. When I visit the page it never loads. The logs say:

Script timed out before returning headers: wsgi.py

我可以通过 ssh 进入服务器并运行 manage.py runserver 然后从另一个终端运行 curl 127.0.0.1:8000,这将成功返回页面.所以我假设它一定是作为 Elastic Beanstalk 一部分设置的 Apache 配置的问题.

I can ssh into the server and run manage.py runserver and then curl 127.0.0.1:8000 from another terminal, which will return the page successfully. So I'm assuming it must be an issue with the Apache configuration that is set up as a part of Elastic Beanstalk.

以下是更多日志:

[pid 15880] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[so:warn] [pid 15880] AH01574: module wsgi_module is already loaded, skipping
[auth_digest:notice] [pid 15880] AH01757: generating secret for digest authentication ...
[lbmethod_heartbeat:notice] [pid 15880] AH02282: No slotmem from mod_heartmonitor
[mpm_prefork:notice] [pid 15880] AH00163: Apache/2.4.9 (Amazon) mod_wsgi/3.4 Python/2.7.5       configured -- resuming normal operations
[core:notice] [pid 15880] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[:error] [pid 15881] /opt/python/run/venv/lib/python2.7/site-packages/numpy/oldnumeric/__init__.py:11: ModuleDeprecationWarning: The oldnumeric module will be dropped in Numpy 1.9
[:error] [pid 15881]   warnings.warn(_msg, ModuleDeprecationWarning)
[:error] [pid 15881] 
[core:error] [pid 15884] [client 10.248.110.45:58996] Script timed out before returning headers: wsgi.py

还有我的 wsgi.py 文件:

And my wsgi.py file:

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "aurora.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

是否有任何可能导致这种情况的线索?

Any clues as to what could be causing this?

更新:

我重建了我的环境并再次遇到了这个问题.我更新了 /etc/httpd/conf.d/wsgi.conf 以包含 WSGIApplicationGroup %{GLOBAL} 如此处所述.我正在使用 Scipy、Numpy 和 GeoDjango(使用 GDAL).我知道 GDAL 并不完全是线程安全的,我不确定其他人,但我假设这是一个线程安全问题.

I rebuilt my environment and ran into this issue again. I updated /etc/httpd/conf.d/wsgi.conf to include WSGIApplicationGroup %{GLOBAL} as mentioned here. I am using Scipy, Numpy, and GeoDjango (which uses GDAL). I know GDAL is not entirely thread safe and I'm not sure about the others but I'm assuming it was a thread safety issue.

推荐答案

2017 年 2 月 8 日更新

以前我的 wsgi.conf 只使用一个进程:

Previously my wsgi.conf was only using one process:

WSGIDaemonProcess wsgi processes=1threads=15 display-name=%{GROUP}

WSGIDaemonProcess wsgi processes=1 threads=15 display-name=%{GROUP}

我将流程提高到更合理的程度,并且没有出现任何问题:

I upped the processes to something more reasonable and haven't had any issues:

WSGIDaemonProcess wsgi processes=6threads=15 display-name=%{GROUP}

WSGIDaemonProcess wsgi processes=6 threads=15 display-name=%{GROUP}

这一变化以及最初添加的 WSGIApplicationGroup %{GLOBAL} 似乎已经成功了.

This change along with the original addition of WSGIApplicationGroup %{GLOBAL} seems to have done the trick.

2015 年 9 月 17 日更新

我仍然偶尔会遇到这个问题.通常,通过 eb deploy 重新部署可以解决此问题.很难说潜在的问题是什么.

I'm still occasionally running in to this issue. Usually, redeploying via eb deploy fixes the issue. It's hard to say what the underlying issue is.

原答案

我最终使项目正常运行,但随后尝试创建一个用于新实例的图像,这又重新打开了问题.我不确定为什么它工作然后停止工作,但我从头开始重建我的自定义 AMI,然后重新推送我的项目.原来这是 wsgi.py 中的一个问题.我发布的版本实际上与部署的版本不同.出于某种原因,另一位开发人员将其放在 wsgi.py 中:

I eventually got the project working but then tried creating an image to use for new instances, which reopened the problem. I'm not sure why it worked then stopped working but I rebuilt my custom AMI from scratch and then repushed my project. Turns out it was an issue in wsgi.py. The version I posted was actually the different from what was being deployed. For some reason another developer had put this in wsgi.py:

path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if path not in sys.path:
sys.path.append(path)

我删除了它并解决了问题.

I removed this and it fixed the problem.

我对任何人的建议

Script timed out before returning headers: wsgi.py

是检查你的 wsgi.py 文件.

is to check you wsgi.py file.

这篇关于脚本在返回标头之前超时:弹性 beantalk 上的 wsgi.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆