* 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
|
# Main loop
|
||||||
|
first = True
|
||||||
while 1:
|
while 1:
|
||||||
confs = get_configs()
|
confs = get_configs()
|
||||||
for app in confs:
|
for app in confs:
|
||||||
@ -55,7 +56,8 @@ while 1:
|
|||||||
|
|
||||||
service_conf = gen(my, app_conf['template'])
|
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'] )
|
sleep( conf['wait_time'] )
|
||||||
|
@ -25,20 +25,30 @@ def write_lock(name, service_conf):
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
def reload_conf(service_conf, app_conf):
|
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)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
write_lock(app_conf['conf_name'], service_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
|
||||||
|
|
||||||
# Check old config
|
|
||||||
if get_old(app_conf['conf_name'], service_conf) != 1:
|
if get_old(app_conf['conf_name'], service_conf) != 1:
|
||||||
print('Write new configuration')
|
stdout = do_reload(service_conf, app_conf)
|
||||||
|
return stdout, first
|
||||||
f = open(app_conf['dest'], 'w')
|
|
||||||
f.write(service_conf)
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
write_lock(app_conf['conf_name'], service_conf)
|
|
||||||
|
|
||||||
# Reload conf
|
|
||||||
stdout = os.popen(app_conf['reload_cmd']).read()
|
|
||||||
return stdout
|
|
||||||
else:
|
else:
|
||||||
return 'Same config. Skip reload'
|
return 'Same config ' + app_conf['conf_name'] + ' Skip reload', first
|
||||||
|
Loading…
Reference in New Issue
Block a user