daydreamer
daydreamer

Reputation: 91969

Flask Application not starting up, server says HTTP 500

My flask app is in $OPENSHIFT_REPO_DIR/repo directory with files as

..repo$ ls
runserver.py app.py 

and my app.py looks like

def run_simple_httpd_server(app, ip, port=8080):
   from wsgiref.simple_server import make_server
   make_server(ip, port, app).serve_forever()

if __name__ == '__main__':
   ip   = os.environ['OPENSHIFT_INTERNAL_IP']
   port = 8080
   from runserver import run
   run_simple_httpd_server(run, ip, port)

while runserver.py looks like

from configuration import app
from core.expense import expense
from core.budget import budget

def run():
    app.register_blueprint(budget)
    app.register_blueprint(expense)
    app.run()

When I restart my app, I do not see anything happening

\> ctl_app restart

when I hit the url in browser it says

A server error occurred. Please contact the administrator.

I do not even see the logs anywhere, what is that I am doing wrong here?

I am doing the deployment for the very first time

Upvotes: 1

Views: 946

Answers (2)

daydreamer
daydreamer

Reputation: 91969

I had to call my application from app.py, I did following and got my app running

cd ~/app_root/repo
vi app.py

# change last part of file to
# you need to do every time code is pushed via git push
if __name__ == '__main__':
   ip   = os.environ['OPENSHIFT_INTERNAL_IP']
   port = 8080
   from runserver import run
   run(ip, port) 

# restart app
ctl_app restart 

and my runserver.py looks like

def run(host, port):
    from configuration import app
    app.run(host=host, port=port)

Upvotes: 0

Nam Duong
Nam Duong

Reputation: 851

How are you deploying your flask application? Are you using the Flask example on github: https://github.com/openshift/flask-example ?

Overall, you shouldn't be required to start your app from ssh on the gear as our start/stop hooks should handle that. Give the flask-example a try. Otherwise, you can review your logs to troubleshoot your 500 error: https://www.openshift.com/faq/how-to-troubleshoot-application-issues-using-logs

Upvotes: 1

Related Questions