Files
notifications-api/aws_run_celery.py
Martyn Inglis 6aec6a0bda Update as per pull request comments:
- context manager for file handling
- os.environ.update for setting overrides
2016-03-17 12:51:14 +00:00

21 lines
574 B
Python

#!/usr/bin/env python
from app import notify_celery, create_app
from credstash import getAllSecrets
import os
from config import configs
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"))
os.environ['NOTIFY_API_ENVIRONMENT'] = configs[environment]
application = create_app()
application.app_context().push()