Add server_commands and update readme.md

Update command to search for services from the user.
This commit is contained in:
Nicholas Staples
2016-05-11 15:52:49 +01:00
parent 55ed143889
commit 15607c0977
6 changed files with 63 additions and 17 deletions

29
server_commands.py Normal file
View File

@@ -0,0 +1,29 @@
from flask.ext.script import Manager, Server
from flask_migrate import Migrate, MigrateCommand
from app import (create_app, db, commands)
from credstash import getAllSecrets
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()
# on aws get secrets and export to env
os.environ.update(getAllSecrets(region="eu-west-1"))
from config import configs
os.environ['NOTIFY_API_ENVIRONMENT'] = configs[environment]
application = create_app()
manager = Manager(application)
migrate = Migrate(application, db)
manager.add_command('db', MigrateCommand)
manager.add_command('purge_functional_test_data', commands.PurgeFunctionalTestDataCommand)
if __name__ == '__main__':
manager.run()