From 3739567b9dc4d2a5547d38e5ddb9bcb1cc11c3b0 Mon Sep 17 00:00:00 2001 From: TLSM Date: Sun, 25 Sep 2022 23:17:43 -0400 Subject: [PATCH] Reload gunicorn on CSS/JS changes. assetcache hashes files on worker startup. We don't really mind a worker reload on asset changes, since that's no worse than the old setup with incrementing numbers. But to make this work smoothly, we listen for changes to the CSS/JS dirs and reload on change. --- gunicorn.conf.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gunicorn.conf.py b/gunicorn.conf.py index ac61df1f8..fe5006c1e 100644 --- a/gunicorn.conf.py +++ b/gunicorn.conf.py @@ -28,3 +28,16 @@ def worker_abort(worker): import os os.abort() +def config_reload_extra_files(): + import os + extra_files = [] + asset_dirs = ['files/assets/css/', 'files/assets/js/'] + + for dir in asset_dirs: + fnames = os.listdir(dir) + paths = map(lambda x: dir + x, fnames) + extra_files.extend(paths) + + return extra_files + +reload_extra_files = config_reload_extra_files()