fix reload worker and readd watch after reload to not only work for one change
This commit is contained in:
parent
b97ce25867
commit
b2b3459fa2
2 changed files with 22 additions and 7 deletions
|
@ -98,7 +98,10 @@ check the README for further details.
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def reloader_thread():
|
def reloader_thread():
|
||||||
|
settings.RELOADER_RUNNING=True
|
||||||
_config_mtime = 0
|
_config_mtime = 0
|
||||||
try:
|
try:
|
||||||
import pyinotify
|
import pyinotify
|
||||||
|
@ -106,11 +109,20 @@ def reloader_thread():
|
||||||
except:
|
except:
|
||||||
INOTIFY = False
|
INOTIFY = False
|
||||||
if INOTIFY:
|
if INOTIFY:
|
||||||
wm = pyinotify.WatchManager()
|
class ConfigChanges:
|
||||||
name = os.path.realpath(settings.SITE_CONFIG)
|
def __init__(self):
|
||||||
wm.add_watch(name, pyinotify.IN_CLOSE_WRITE, lambda event: load_config())
|
name = os.path.realpath(settings.SITE_CONFIG)
|
||||||
notifier = pyinotify.Notifier(wm)
|
self.name = name
|
||||||
notifier.loop()
|
self.wm = pyinotify.WatchManager()
|
||||||
|
self.reload_config()
|
||||||
|
notifier = pyinotify.Notifier(self.wm)
|
||||||
|
notifier.loop()
|
||||||
|
|
||||||
|
def reload_config(self):
|
||||||
|
load_config()
|
||||||
|
self.wm.add_watch(self.name, pyinotify.IN_CLOSE_WRITE,
|
||||||
|
lambda event: self.reload_config())
|
||||||
|
ConfigChanges()
|
||||||
else:
|
else:
|
||||||
while RUN_RELOADER:
|
while RUN_RELOADER:
|
||||||
try:
|
try:
|
||||||
|
@ -205,5 +217,6 @@ def update_geoip(force=False):
|
||||||
os.system('gunzip "%s.gz"' % path)
|
os.system('gunzip "%s.gz"' % path)
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
load_config()
|
if not settings.RELOADER_RUNNING:
|
||||||
thread.start_new_thread(reloader_thread, ())
|
load_config()
|
||||||
|
thread.start_new_thread(reloader_thread, ())
|
||||||
|
|
|
@ -206,6 +206,8 @@ LIST_ICON = join(SCRIPT_ROOT, 'list_icon.py')
|
||||||
|
|
||||||
DB_GIN_TRGM = False
|
DB_GIN_TRGM = False
|
||||||
|
|
||||||
|
|
||||||
|
RELOADER_RUNNING = False
|
||||||
#you can ignore things below this line
|
#you can ignore things below this line
|
||||||
#=========================================================================
|
#=========================================================================
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue