ensure app can run on paas

instead of using wsgi, we now use "application" - this tells gunicorn
to look inside the python module application (application.py) for a
wsgi app - and by default that is also called application so rename
the variable.

Also, when running tasks, we're not using gunicorn so need to set the
flask variable in the manifest so that `flask command ...` finds the
app properly.

Remove server_commands as it's not used any more.
This commit is contained in:
Leo Hemsted
2017-11-22 16:31:04 +00:00
parent cd6f85281c
commit b727f53836
3 changed files with 4 additions and 26 deletions

View File

@@ -5,6 +5,6 @@ from flask import Flask
from app import create_app
app = Flask('app')
application = Flask('app')
create_app(app)
create_app(application)

View File

@@ -14,6 +14,8 @@ services:
env:
NOTIFY_APP_NAME: public-api
CW_APP_NAME: api
# required by cf run-task
FLASK_APP: application.py
instances: 1
memory: 1G

View File

@@ -1,24 +0,0 @@
from flask_migrate import Migrate, MigrateCommand
from app import (create_app, db, commands)
import os
default_env_file = '/home/ubuntu/environment'
environment = 'live'
if os.path.isfile(default_env_file):
with open(default_env_file, 'r') as environment_file:
environment = environment_file.readline().strip()
from app.config import configs
os.environ['NOTIFY_API_ENVIRONMENT'] = configs[environment]
application = create_app()
migrate = Migrate(application, db)
application.add_command('db', MigrateCommand)
application.add_command('purge_functional_test_data', commands.PurgeFunctionalTestDataCommand)
application.add_command('custom_db_script', commands.CustomDbScript)
if __name__ == '__main__':
manager.run()