def main(): service.prepare_service(sys.argv) gmr.TextGuruMeditation.setup_autorun(version) timestamp = str(datetime.datetime.utcnow()) LOG.info("Starting house keeping at %s", timestamp) # Thread to perform spare amphora check spare_amp_thread = threading.Thread(target=spare_amphora_check) spare_amp_thread.daemon = True spare_amp_thread.start() # Thread to perform db cleanup db_cleanup_thread = threading.Thread(target=db_cleanup) db_cleanup_thread.daemon = True db_cleanup_thread.start() signal.signal(signal.SIGHUP, _mutate_config) # Try-Exception block should be at the end to gracefully exit threads try: while True: time.sleep(1) except KeyboardInterrupt: LOG.info("Attempting to gracefully terminate House-Keeping") spare_amp_thread_event.set() db_cleanup_thread_event.set() spare_amp_thread.join() db_cleanup_thread.join() LOG.info("House-Keeping process terminated")
def main(): octavia_service.prepare_service(sys.argv) gmr.TextGuruMeditation.setup_autorun(version) sm = cotyledon.ServiceManager() sm.add(consumer.ConsumerService, workers=CONF.a10_controller_worker.workers, args=(CONF, )) oslo_config_glue.setup(sm, CONF, reload_method="mutate") sm.run()
def main(): service.prepare_service(sys.argv) gmr.TextGuruMeditation.setup_autorun(version) processes = [] exit_event = multiprocessing.Event() hm_listener_proc = multiprocessing.Process(name='HM_listener', target=hm_listener, args=(exit_event, )) processes.append(hm_listener_proc) hm_health_check_proc = multiprocessing.Process(name='HM_health_check', target=hm_health_check, args=(exit_event, )) processes.append(hm_health_check_proc) LOG.info("A10 Health Manager listener process starts:") hm_listener_proc.start() LOG.info("A10 Health manager check process starts:") hm_health_check_proc.start() def process_cleanup(*args, **kwargs): LOG.info("A10 Health Manager exiting due to signal") exit_event.set() os.kill(hm_health_check_proc.pid, signal.SIGINT) hm_health_check_proc.join() hm_listener_proc.join() signal.signal(signal.SIGTERM, process_cleanup) signal.signal( signal.SIGHUP, partial(health_manager._handle_mutate_config, hm_listener_proc.pid, hm_health_check_proc.pid)) try: for process in processes: process.join() except KeyboardInterrupt: process_cleanup()