Better error handling, Efforts to run non-root with occasional sudo

This commit is contained in:
ahmadbilalkhalid 2019-12-29 23:14:39 +05:00
commit f980cdb464
7 changed files with 90 additions and 47 deletions

View file

@ -14,10 +14,8 @@ from . import virtualmachine, logger
def update_heartbeat(hostname):
"""Update Last HeartBeat Time for :param hostname: in etcd"""
host_pool = shared.host_pool
this_host = next(filter(lambda h: h.hostname == hostname, host_pool.hosts), None)
while True:
this_host.update_heartbeat()
host_pool.put(this_host)
@ -43,7 +41,7 @@ def main(hostname):
heartbeat_updating_process = mp.Process(target=update_heartbeat, args=(hostname,))
heartbeat_updating_process.start()
except Exception as e:
raise e.__class__('ucloud-host heartbeat updating mechanism is not working') from e
raise Exception('ucloud-host heartbeat updating mechanism is not working') from e
for events_iterator in [
shared.etcd_client.get_prefix(settings['etcd']['request_prefix'], value_in_json=True),
@ -87,7 +85,7 @@ def main(hostname):
if __name__ == "__main__":
argparser = argparse.ArgumentParser()
argparser.add_argument("hostname", help="Name of this host. e.g /v1/host/1")
argparser.add_argument("hostname", help="Name of this host. e.g uncloud1.ungleich.ch")
args = argparser.parse_args()
mp.set_start_method('spawn')
main(args.hostname)