aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md64
-rw-r--r--app/app/settings.py23
-rw-r--r--app/config.yml10
-rw-r--r--app/uwsgi.ini2
4 files changed, 96 insertions, 3 deletions
diff --git a/README.md b/README.md
index 2d3222c..1d25000 100644
--- a/README.md
+++ b/README.md
@@ -40,3 +40,67 @@ pip install -r requirements.txt
./manage.py runserver 0.0.0.0:8080
```
+
+
+To get a production system setup:
+
+
+``` bash
+export CFG="my-config.yml"
+cd app
+virtualenv env
+. env/bin/activate
+pip install -r requirements.txt
+cp config.yml $CFG
+vi $CFG # This is where you change the SECRET_KEY, static_root, allowed_hosts
+# and other settings.
+cat uwsgi.ini | sed -e"s/config.yml/$CFG/g" > my-uwsgi.ini
+./manage.py collectstatic
+./manage.py migrate
+./manage.py createsuperuser
+uwsgi --ini my-uwsgi.ini # This will start the daemon, it's up to you to
+# configure your OS to start it on boot
+```
+
+Below is a sample Nginx configuration, edit for your needs:
+
+``` nginx
+# It's up to you to configure HTTPs, I _highly_ recommend it
+server {
+ listen 80;
+ # Uncomment if you have ipv6
+ # listen [::]:80;
+ server_name dispatch.example.com;
+
+ root /var/www/dispatch.example.com;
+
+ index index.html index.htm;
+
+ # Some applications have trouble with merged slashes
+ # This likely doesn't but worth noting
+ merge_slashes off;
+
+ location / {
+ include uwsgi_params;
+ uwsgi_pass 127.0.0.1:9200;
+ }
+
+ # Pass through the static directory
+ # This should match whatever is in your config file
+ location /static {
+ alias /var/www/dispatch.example.com/static;
+ }
+
+ # This is probably going to be pulled from dispatch/static/robots.txt
+ location /robots.txt {
+ alias /var/www/dispatch.example.com/static/robots.txt;
+ }
+
+ # Enable logging
+ # You will likely have to create these directories for Nginx to load
+ access_log /var/log/nginx/dispatch.example.com/access.log;
+ error_log /var/log/nginx/dispatch.example.com/error.log;
+
+}
+```
+
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