From b7d282a8ba5f0ed6c773989c96c2182257cc69a5 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Tue, 31 Oct 2017 22:53:29 -0400 Subject: Some changes to make deployment easier --- app/app/settings.py | 23 ++++++++++++++++++++--- app/config.yml | 10 ++++++++++ app/uwsgi.ini | 2 ++ 3 files changed, 32 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/app/settings.py b/app/app/settings.py index d472675..f143931 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -16,20 +16,37 @@ import yaml # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -CONFIG = yaml.load(open(BASE_DIR + '/config.yml').read()) + +def get_default_config(): + return yaml.load(open(BASE_DIR + '/config.yml').read()) + + +CONFIG = {} + +if os.environ.get('CUSTOM_CONFIG'): + try: + fn = "{}/{}".format(BASE_DIR, os.environ.get('CUSTOM_CONFIG')) + CONFIG = yaml.load(open(fn)) + except Exception as e: + print("WARNING: Loading default configuration. \n{}".format(e)) + CONFIG = get_default_config() +else: + CONFIG = get_default_config() # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'h$r_bwlp@#h#y#%&qhw-n=gb2%wva1d_h65+o94u&!a#%iv&lo' +SECRET_KEY = CONFIG['SECRET_KEY'] # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = CONFIG['debug'] ALLOWED_HOSTS = CONFIG['allowed_hosts'] +ADMINS = CONFIG['admins'] + # Application definition diff --git a/app/config.yml b/app/config.yml index 66ac993..8c39278 100644 --- a/app/config.yml +++ b/app/config.yml @@ -25,3 +25,13 @@ allowed_hosts: - 127.0.0.1 static_root: '/full/path/to/static/root' + +debug: True + +# CHANGE THIS BEFORE USING IN PRODUCTION +SECRET_KEY: 'h$r_bwlp@#h#y#%&qhw-n=gb2%wva1d_h65+o94u&!a#%iv&lo' + +# These people will be emailed if debug = false +admins: + - 'bob@example.com' + diff --git a/app/uwsgi.ini b/app/uwsgi.ini index 5b7b516..829d185 100644 --- a/app/uwsgi.ini +++ b/app/uwsgi.ini @@ -2,6 +2,8 @@ processes = 1 threads = 4 +env = CUSTOM_CONFIG=config.yml + socket = 127.0.0.1:9200 module = wsgi:application -- cgit v1.2.3