diff options
Diffstat (limited to 'miss_htbt_service/cbs_polling.py')
-rw-r--r-- | miss_htbt_service/cbs_polling.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/miss_htbt_service/cbs_polling.py b/miss_htbt_service/cbs_polling.py index 8d5af09..3832b71 100644 --- a/miss_htbt_service/cbs_polling.py +++ b/miss_htbt_service/cbs_polling.py @@ -33,7 +33,7 @@ import get_logger _logger = get_logger.get_logger(__name__) -def pollCBS(current_pid): +def poll_cbs(current_pid: int) -> None: jsfile = db.fetch_json_file() ip_address, port_num, user_name, password, db_name, cbs_polling_required, cbs_polling_interval = db.read_hb_properties(jsfile) hbc_pid, hbc_state, hbc_srcName, hbc_time = db.read_hb_common(user_name, password, ip_address, port_num, db_name) @@ -50,18 +50,20 @@ def pollCBS(current_pid): hbc_pid, hbc_state, hbc_srcName, hbc_time = db.read_hb_common(user_name, password, ip_address, port_num, db_name) source_name = socket.gethostname() source_name = source_name + "-" + str(os.getenv('SERVICE_NAME', "")) - result = True - if int(current_pid) == int(hbc_pid) and source_name == hbc_srcName and hbc_state == "RUNNING": + if current_pid == int(hbc_pid) and source_name == hbc_srcName and hbc_state == "RUNNING": _logger.info("CBSP:ACTIVE Instance:Change the state to RECONFIGURATION") state = "RECONFIGURATION" update_flg = 1 db.create_update_hb_common(update_flg, hbc_pid, state, user_name, password, ip_address, port_num, db_name) else: _logger.info("CBSP:Inactive instance or hb_common state is not RUNNING") - return result -if __name__ == "__main__": - current_pid = sys.argv[1] +def cbs_polling_loop(current_pid: int): while True: - pollCBS(current_pid) + poll_cbs(current_pid) + + +if __name__ == "__main__": + parent_pid = int(sys.argv[1]) + cbs_polling_loop(parent_pid) |