Skip to content

Instantly share code, notes, and snippets.

@D2theR
Last active June 1, 2023 21:10
Show Gist options
  • Save D2theR/36e8cebcd3d9b0a3b0472e3ba117fb54 to your computer and use it in GitHub Desktop.
Save D2theR/36e8cebcd3d9b0a3b0472e3ba117fb54 to your computer and use it in GitHub Desktop.
A simple Gunicorn config script that can be used to add your Django template file directories the reload engine to prevent having to reloading the server in development every time you make a change.
##Gunicorn config file
"""
USAGE
gunicorn -b 127.0.0.1:8888 -c gunicorn.conf.py myapp.wsgi
"""
import os, pathlib
template_root = pathlib.Path('/full/path/to/myapp/templates/')
template_list = []
for path, subdirs, files in os.walk(template_root):
for name in files:
template_list.append(str(pathlib.PurePath(path, name)))
chdir = '/full/path/to/myapp/'
reload_extra_files = template_list
workers = 1
reload = True
loglevel = 'debug'
raw_env = ['DJANGO_SETTINGS_MODULE=mysite.settings.py']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment