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