* Detect new run
* More information in stdout
This commit is contained in:
parent
b5de8381f6
commit
4c8acc6bc8
4
surok.py
4
surok.py
@ -42,6 +42,7 @@ def load_app_conf(app):
|
||||
|
||||
|
||||
# Main loop
|
||||
first = True
|
||||
while 1:
|
||||
confs = get_configs()
|
||||
for app in confs:
|
||||
@ -55,7 +56,8 @@ while 1:
|
||||
|
||||
service_conf = gen(my, app_conf['template'])
|
||||
|
||||
print( reload_conf(service_conf, app_conf) )
|
||||
stdout, first = reload_conf(service_conf, app_conf, first)
|
||||
print(stdout)
|
||||
|
||||
|
||||
sleep( conf['wait_time'] )
|
||||
|
@ -25,11 +25,8 @@ def write_lock(name, service_conf):
|
||||
f.close()
|
||||
|
||||
|
||||
def reload_conf(service_conf, app_conf):
|
||||
|
||||
# Check old config
|
||||
if get_old(app_conf['conf_name'], service_conf) != 1:
|
||||
print('Write new configuration')
|
||||
def do_reload(service_conf, app_conf):
|
||||
print( 'Write new configuration of ' + app_conf['conf_name'] )
|
||||
|
||||
f = open(app_conf['dest'], 'w')
|
||||
f.write(service_conf)
|
||||
@ -40,5 +37,18 @@ def reload_conf(service_conf, app_conf):
|
||||
# Reload conf
|
||||
stdout = os.popen(app_conf['reload_cmd']).read()
|
||||
return stdout
|
||||
|
||||
|
||||
def reload_conf(service_conf, app_conf, first):
|
||||
|
||||
# Check first loop
|
||||
if first == True:
|
||||
stdout = do_reload(service_conf, app_conf)
|
||||
first = False
|
||||
return stdout, first
|
||||
|
||||
if get_old(app_conf['conf_name'], service_conf) != 1:
|
||||
stdout = do_reload(service_conf, app_conf)
|
||||
return stdout, first
|
||||
else:
|
||||
return 'Same config. Skip reload'
|
||||
return 'Same config ' + app_conf['conf_name'] + ' Skip reload', first
|
||||
|
Loading…
Reference in New Issue
Block a user