From 06c1429af74c781bf68eee3aac1933bfa0ed96f0 Mon Sep 17 00:00:00 2001 From: felipe Date: Fri, 15 Apr 2016 00:34:12 +0300 Subject: [PATCH] Add an example to demonstrate using a Django setting file as Gunicorn config --- examples/read_django_settings.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 examples/read_django_settings.py diff --git a/examples/read_django_settings.py b/examples/read_django_settings.py new file mode 100644 index 00000000..045fa242 --- /dev/null +++ b/examples/read_django_settings.py @@ -0,0 +1,21 @@ +""" +Use this config file in your script like this: + + $ gunicorn project_name.wsgi:application -c read_django_settings.py + +You need to replace the exec() call if you want it to work on Python 2. +""" + +settings_dict = {} + +with open('frameworks/django/testing/testing/settings.py') as f: + exec(f.read(), settings_dict) + +loglevel = 'warning' +proc_name = 'web-project' +workers = 1 + +if settings_dict['DEBUG']: + loglevel = 'debug' + reload = True + proc_name += '_debug'