脚本在返回标头之前超时:application.py

时间:2016-11-29 04:56:12

标签: python amazon-web-services flask mod-wsgi wsgi

我一直在尝试使用弹性beanstalk服务在aws上部署我的烧瓶应用程序,但我有运气。我尝试将应用程序重命名为应用程序或导入为应用程序。我试过在httpf.conf中添加不同的东西。但是,没有运气。

有什么想法吗?

以下是我正在使用/遇到的一些例子。

[Tue Nov 29 04:36:57.477486 2016] [mpm_prefork:notice] [pid 28202] AH00169: caught SIGTERM, shutting down
[Tue Nov 29 04:36:58.593231 2016] [suexec:notice] [pid 28480] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Tue Nov 29 04:36:58.622166 2016] [so:warn] [pid 28480] AH01574: module wsgi_module is already loaded, skipping
[Tue Nov 29 04:36:58.627404 2016] [auth_digest:notice] [pid 28480] AH01757: generating secret for digest authentication ...
[Tue Nov 29 04:36:58.628967 2016] [lbmethod_heartbeat:notice] [pid 28480] AH02282: No slotmem from mod_heartmonitor
[Tue Nov 29 04:36:58.664458 2016] [mpm_prefork:notice] [pid 28480] AH00163: Apache/2.4.23 (Amazon) mod_wsgi/3.5 Python/3.4.3 configured -- resuming normal operations
[Tue Nov 29 04:36:58.667914 2016] [core:notice] [pid 28480] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Tue Nov 29 04:37:02.142727 2016] [:error] [pid 28485]  * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
[Tue Nov 29 04:38:05.392413 2016] [core:error] [pid 28509] [client 127.0.0.1:47208] Script timed out before returning headers: application.py
[Tue Nov 29 04:38:09.386271 2016] [core:error] [pid 28508] [client 127.0.0.1:47210] Script timed out before returning headers: application.py
[Tue Nov 29 04:38:13.392044 2016] [core:error] [pid 28506] [client 127.0.0.1:47212] Script timed out before returning headers: application.py
[Tue Nov 29 04:39:04.713037 2016] [core:error] [pid 28532] [client 172.31.63.245:56919] Script timed out before returning headers: application.py

application.py

from project_test import app as application
from project_test.models import db

project_test .__初始化__。PY

from flask import Flask
from datetime import timedelta
from flask_mail import Message, Mail

from flask_login import LoginManager

from project_test.models import db, User

import os

mail = Mail()
app = Flask(__name__)

# app.config.from_object(os.environ['APP_SETTINGS'])

app.config["APP_SETTINGS"] = "project_test.config.DevConfig"
app.config.from_object(app.config["APP_SETTINGS"])

mail.init_app(app)

app.permanent_session_lifetime = timedelta(seconds=900)

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'
login_manager.login_message_category = "danger"

@login_manager.user_loader
def load_user(user_id):
    return User.query.filter(User.id == int(user_id)).first()

import project_test.views

谢谢!

1 个答案:

答案 0 :(得分:2)

这是因为您在代码中的某个位置启动了内置的Flask开发人员服务器。从消息中可以看出这一点:

Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

通常这是因为app.run()被调用,但这在你所展示的内容中并不明显。

无论哪种方式,你都不应该启动Flask开发服务器,因为Apache下的mod_wsgi充当了WSGI服务器。