← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Thiago F. Pappacena has proposed merging ~pappacena/launchpad:gunicorn-reload-extra-files into launchpad:master.

Commit message:
When in development, auto reload gunicorn on config changes

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/397814
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/launchpad:gunicorn-reload-extra-files into launchpad:master.
diff --git a/configs/development/gunicorn.conf.py b/configs/development/gunicorn.conf.py
index b667109..4c92503 100644
--- a/configs/development/gunicorn.conf.py
+++ b/configs/development/gunicorn.conf.py
@@ -1,6 +1,33 @@
+from fnmatch import fnmatch
+import os
+
+
+BASE_DIR = os.path.realpath(
+    os.path.join(os.path.dirname(__file__), '..', '..'))
+CONFIG_DIR = os.path.dirname(__file__)
+
+
+def find_files(directory, pattern):
+    """Find files in `directory` matching `pattern`.
+    """
+    result = []
+    for root, dirs, files in os.walk(directory):
+        for basename in files:
+            matches = fnmatch(basename, pattern)
+            if matches:
+                filename = os.path.join(root, basename)
+                result.append(filename)
+    return result
+
+
 bind = [":8085", ":8086", ":8087", ":8088", ":8089"]
 workers = 2
 threads = 10
 max_requests = 1000
 log_level = "DEBUG"
 reload = True
+
+# Watch config files changes from the source tree.
+reload_extra_files = find_files(CONFIG_DIR, "*")
+for pattern in ["*.zcml", "*.conf"]:
+    reload_extra_files += find_files(os.path.join(BASE_DIR, 'lib'), pattern)

Follow ups