Fallback to files if memcached is down

This commit is contained in:
Denis Zheleztsov 2016-11-09 15:31:57 +03:00
parent d5b448b133
commit b261486c76

View File

@ -68,14 +68,6 @@ def do_reload(service_conf, app_conf):
# !!! NEED REFACTORING !!!
def reload_conf(service_conf, app_conf, conf, app_hosts):
# Check first loop
#if first is True:
# stdout = do_reload(service_conf, app_conf)
# first = False
# logging.info(stdout)
# return first
# Check marathon enabled in configuration
if conf['marathon']['enabled'] is True:
if get_old(app_conf['conf_name'], service_conf) != 1:
@ -88,13 +80,15 @@ def reload_conf(service_conf, app_conf, conf, app_hosts):
if conf['memcached']['enabled'] is True:
# Check old servers
if conf['memcached']['discovery']['enabled'] is True:
logging.warning('Discovery of Memcached not implemented')
logging.warning('Discovery of Memcached not implpemented')
try:
mc = memcache.Client(conf['memcached']['hosts'])
if get_old_from_memcache(mc, app_conf['conf_name'], service_conf) != 1:
stdout = do_reload(service_conf, app_conf)
logging.info(stdout)
return True
except Exception as e:
logging.error('Cannot connect to memcached: ' + str(e))
else:
logging.warning('DEPRECATED main conf file. Please use new syntax!')
@ -130,4 +124,3 @@ def restart_self_in_marathon(marathon):
r = requests.post(uri, data = {'force': 'true'})
else:
r = requests.post(uri, data = {'force': 'false'})