Start aligning Admin app with config styles used elsewhere

- no config overrides - now all set in environment
- use different files for staging and live too allow for differently named env variables
- updates to run_app and run_tests scripts to set correct environment (test/development) so correct config picked up
- use environment file on deployed environments to pick correct config
This commit is contained in:
Martyn Inglis
2016-03-17 13:45:59 +00:00
parent 85348c05b3
commit 2473b09beb
8 changed files with 55 additions and 36 deletions

16
wsgi.py
View File

@@ -2,16 +2,22 @@ from app import create_app
from credstash import getAllSecrets
import os
config = 'live'
default_env_file = '/home/ubuntu/environment'
environment = 'live'
if os.path.isfile(default_env_file):
environment = open(default_env_file, 'r')
config = environment.readline().strip()
with open(default_env_file, 'r') as environment_file:
environment = environment_file.readline().strip()
secrets = getAllSecrets(region="eu-west-1")
application = create_app(config, secrets)
# on aws get secrets and export to env
os.environ.update(getAllSecrets(region="eu-west-1"))
from config import configs
os.environ['NOTIFY_ADMIN_ENVIRONMENT'] = configs[environment]
application = create_app()
if __name__ == "__main__":
application.run()