1

I have been trying to deploy my flask app on aws using their elastic beanstalk service but I havnt had any luck. I have tried renaming app to application or import as application. I have tried adding different things to httpf.conf. But, no luck.

Any ideas?

Here is some examples of what i am using/running into.

[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.__init__.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

Thank you!

1 Answers1

2

This is because somewhere in your code you are starting the builtin Flask developer server. This is evident from the message:

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

Usually this is because app.run() is being called, but that is not evident in what you have shown.

Either way, you shouldn't be starting up the Flask development server as mod_wsgi under Apache is acting as the WSGI server.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • it was these lines that did it... app.config["APP_SETTINGS"] = "northtrack.config.DevConfig" app.config.from_object(app.config["APP_SETTINGS"]). Thanks! – Adnan Dossaji Nov 29 '16 at 05:33
  • 1
    Those lines shouldn't start the builtin developer server which was problem I was highlighting. Maybe you hadn't restarted Apache after some prior change where you removed what was causing it. – Graham Dumpleton Nov 29 '16 at 05:41
  • You are correct. I added those lines in after restarting apache and it worked. It was app.run() that was doing it but i never restarted Apache. Thanks again! – Adnan Dossaji Nov 29 '16 at 05:50
  • just put app.run under... if __name__ == "__main__": – Adi Jan 22 '17 at 22:35