I have working flask app on my development server of flask which works fine. Now i want to take it one step further to deploy it using the gunicorn i have following code in which i can launch gunicorn but my application some where in middle drop connection but it works very fine DEV server.
I would like to know how to enable logging on with gunicorn.
I review the following que but could not get much information How to use Flask-Script and Gunicorn
My Application has following structure and /home/webusr/svsapp/svsappenv
manage.py has following code updated my manage.py with respect to following blog post
#!/usr/bin/env python
import os
import sys
from gunicorn.app.base import Application
from app import create_app,db
from flask.ext.script import Manager, Shell , Server
from flask.ext.migrate import Migrate, MigrateCommand
from flask_script import Command,Option
from app.models import SVSFaceTab,SVSuserReg,SVSIpCamReg
app = create_app(os.getenv('SVS_CONFIG') or 'default')
manager = Manager(app)
migrate = Migrate(app, db)
def make_shell_context():
return dict(app=app, db=db,SVSuserReg=SVSuserReg,SVSIpCamReg=SVSIpCamReg,SVSFaceTab=SVSFaceTab)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command('db', MigrateCommand)
@manager.option('-h', '--host', dest='host', default='169.38.74.171')
@manager.option('-p', '--port', dest='port', type=int, default=8080)
@manager.option('-w', '--workers', dest='workers', type=int, default=10)
@manager.option('-t', '--timeout', dest='timeout', type=int ,default=90)
def gunicorn(host, port, workers,timeout):
"""Start the Server with Gunicorn"""
from gunicorn.app.base import Application
class FlaskApplication(Application):
def init(self, parser, opts, args):
return {
'bind': '{0}:{1}'.format(host, port),
'workers': workers,'timeout' : timeout
}
def load(self):
return app
application = FlaskApplication()
return application.run()
@manager.command
def test():
"""Run the unit tests."""
import unittest
tests = unittest.TestLoader().discover('tests')
unittest.TextTestRunner(verbosity=2).run(tests)
if __name__ == '__main__':
manager.run()
$ python manage.py gunicorn