use pyinotify to watch for config changes if installed

This commit is contained in:
j 2013-01-31 08:44:30 +00:00
parent 31652fe3d8
commit c576e347a8
2 changed files with 26 additions and 13 deletions

View File

@ -96,19 +96,31 @@ check the README for further details.
def reloader_thread():
_config_mtime = 0
while RUN_RELOADER:
try:
stat = os.stat(settings.SITE_CONFIG)
mtime = stat.st_mtime
if _win:
mtime -= stat.st_ctime
if mtime > _config_mtime:
load_config()
_config_mtime = mtime
except:
#sys.stderr.write("reloading config failed\n")
pass
time.sleep(1)
try:
import pyinotify
INOTIFY = True
except:
INOTIFY = False
if INOTIFY:
wm = pyinotify.WatchManager()
name = os.path.realpath(settings.SITE_CONFIG)
wm.add_watch(name, pyinotify.IN_CLOSE_WRITE, lambda event: load_config())
notifier = pyinotify.Notifier(wm)
notifier.loop()
else:
while RUN_RELOADER:
try:
stat = os.stat(settings.SITE_CONFIG)
mtime = stat.st_mtime
if _win:
mtime -= stat.st_ctime
if mtime > _config_mtime:
load_config()
_config_mtime = mtime
time.sleep(1)
except:
#sys.stderr.write("reloading config failed\n")
pass
def update_static():
oxjs_build = os.path.join(settings.STATIC_ROOT, 'oxjs/tools/build/build.py')

View File

@ -34,6 +34,7 @@ sudo vmbuilder vbox ubuntu --suite=precise \
--addpkg python-imaging \
--addpkg python-numpy \
--addpkg python-psycopg2 \
--addpkg python-pyinotify \
--addpkg python-simplejson \
--addpkg python-lxml \
--addpkg python-html5lib \