Add log level and test for functions
This commit is contained in:
parent
7d441d6386
commit
733e73ae58
5 changed files with 179 additions and 37 deletions
28
src/main.py
28
src/main.py
|
|
@ -20,7 +20,7 @@ def start():
|
|||
processor_obj.save_config(haproxy_config)
|
||||
processor_obj.save_certs(certs_haproxy)
|
||||
letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts()
|
||||
Functions.log('EASYHAPROXY', 'debug', 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to after save_config
|
||||
Functions.log(Functions.EASYHAPROXY_LOG, Functions.DEBUG, 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to after save_config
|
||||
|
||||
old_haproxy = None
|
||||
haproxy = DaemonizeHAProxy()
|
||||
|
|
@ -37,11 +37,11 @@ def start():
|
|||
old_parsed = processor_obj.get_parsed_object()
|
||||
processor_obj.refresh()
|
||||
if DeepDiff(old_parsed, processor_obj.get_parsed_object()) != {} or not haproxy.is_alive():
|
||||
Functions.log('EASYHAPROXY', 'debug', 'New configuration found. Reloading...')
|
||||
Functions.log(Functions.EASYHAPROXY_LOG, Functions.DEBUG, 'New configuration found. Reloading...')
|
||||
processor_obj.save_config(haproxy_config)
|
||||
processor_obj.save_certs(certs_haproxy)
|
||||
letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts()
|
||||
Functions.log('EASYHAPROXY', 'debug', 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to after save_config
|
||||
Functions.log(Functions.EASYHAPROXY_LOG, Functions.DEBUG, 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to after save_config
|
||||
old_haproxy = haproxy
|
||||
haproxy = DaemonizeHAProxy()
|
||||
haproxy.haproxy("reload")
|
||||
|
|
@ -49,26 +49,26 @@ def start():
|
|||
|
||||
certbot.check_certificates(letsencrypt_certs_found)
|
||||
except Exception as e:
|
||||
Functions.log('EASYHAPROXY', 'fatal', "Err: %s" % (e))
|
||||
Functions.log('EASYHAPROXY', 'debug', 'Heartbeat')
|
||||
Functions.log(Functions.EASYHAPROXY_LOG, Functions.FATAL, "Err: %s" % (e))
|
||||
Functions.log(Functions.EASYHAPROXY_LOG, Functions.DEBUG, 'Heartbeat')
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
Functions.run_bash('INIT', '/usr/sbin/haproxy -v')
|
||||
Functions.run_bash(Functions.INIT_LOG, '/usr/sbin/haproxy -v')
|
||||
|
||||
Functions.log('INIT', 'info', " _ ")
|
||||
Functions.log('INIT', 'info', " ___ __ _ ____ _ ___| |_ __ _ _ __ _ _ _____ ___ _ ")
|
||||
Functions.log('INIT', 'info', "/ -_) _` (_-< || |___| ' \/ _` | '_ \ '_/ _ \ \ / || |")
|
||||
Functions.log('INIT', 'info', "\___\__,_/__/\_, | |_||_\__,_| .__/_| \___/_\_\\_, |")
|
||||
Functions.log('INIT', 'info', " |__/ |_| |__/ ")
|
||||
Functions.log(Functions.INIT_LOG, Functions.INFO, " _ ")
|
||||
Functions.log(Functions.INIT_LOG, Functions.INFO, " ___ __ _ ____ _ ___| |_ __ _ _ __ _ _ _____ ___ _ ")
|
||||
Functions.log(Functions.INIT_LOG, Functions.INFO, "/ -_) _` (_-< || |___| ' \/ _` | '_ \ '_/ _ \ \ / || |")
|
||||
Functions.log(Functions.INIT_LOG, Functions.INFO, "\___\__,_/__/\_, | |_||_\__,_| .__/_| \___/_\_\\_, |")
|
||||
Functions.log(Functions.INIT_LOG, Functions.INFO, " |__/ |_| |__/ ")
|
||||
|
||||
Functions.log('INIT', 'info', "Release: %s" % (os.getenv("RELEASE_VERSION")))
|
||||
Functions.log('INIT', 'debug', 'Environment:')
|
||||
Functions.log(Functions.INIT_LOG, Functions.INFO, "Release: %s" % (os.getenv("RELEASE_VERSION")))
|
||||
Functions.log(Functions.INIT_LOG, Functions.DEBUG, 'Environment:')
|
||||
for name, value in os.environ.items():
|
||||
if "HAPROXY" in name:
|
||||
Functions.log('INIT', 'debug', "- {0}: {1}".format(name, value))
|
||||
Functions.log(Functions.INIT_LOG, Functions.DEBUG, "- {0}: {1}".format(name, value))
|
||||
|
||||
start()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue