Merge ~pappacena/launchpad:gunicorn-reload-extra-files into launchpad:master

Proposed by Thiago F. Pappacena
Status: Merged
Approved by: Thiago F. Pappacena
Approved revision: e10a808de55f135b2114f975ac8eb725d804c9e8
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~pappacena/launchpad:gunicorn-reload-extra-files
Merge into: launchpad:master
Diff against target: 41 lines (+30/-0)
1 file modified
configs/development/gunicorn.conf.py (+30/-0)
Reviewer Review Type Date Requested Status
Tom Wardill (community) Approve
Review via email: mp+397814@code.launchpad.net

Commit message

When in development, auto reload gunicorn on config changes

To post a comment you must log in.
Revision history for this message
Tom Wardill (twom) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/configs/development/gunicorn.conf.py b/configs/development/gunicorn.conf.py
2index b667109..2c914aa 100644
3--- a/configs/development/gunicorn.conf.py
4+++ b/configs/development/gunicorn.conf.py
5@@ -1,6 +1,36 @@
6+from fnmatch import fnmatch
7+import os
8+
9+
10+BASE_DIR = os.path.realpath(
11+ os.path.join(os.path.dirname(__file__), '..', '..'))
12+CONFIG_DIR = os.path.dirname(__file__)
13+
14+
15+def find_files(directory, pattern):
16+ """Find files in `directory` matching `pattern`.
17+ """
18+ result = []
19+ for root, dirs, files in os.walk(directory):
20+ for basename in files:
21+ matches = fnmatch(basename, pattern)
22+ if matches:
23+ filename = os.path.join(root, basename)
24+ result.append(filename)
25+ return result
26+
27+
28 bind = [":8085", ":8086", ":8087", ":8088", ":8089"]
29 workers = 2
30 threads = 10
31 max_requests = 1000
32 log_level = "DEBUG"
33+
34+# Keeping a really long timeout in development to allow us to ipdb calmly.
35+timeout = 15 * 60
36+
37 reload = True
38+# Watch config files changes from the source tree.
39+reload_extra_files = find_files(CONFIG_DIR, "*")
40+for pattern in ["*.zcml", "*.conf"]:
41+ reload_extra_files += find_files(os.path.join(BASE_DIR, 'lib'), pattern)