diff --git a/files/scripts/supervisor-proc-exit-listener b/files/scripts/supervisor-proc-exit-listener index 1b8a7e04ba..61c12d8ce4 100755 --- a/files/scripts/supervisor-proc-exit-listener +++ b/files/scripts/supervisor-proc-exit-listener @@ -90,12 +90,12 @@ def generate_alerting_message(process_name, status, dead_minutes): .format(process_name, status, namespace, dead_minutes)) -def get_autorestart_state(container_name): +def get_autorestart_state(container_name, use_unix_socket_path): """ @summary: Read the status of auto-restart feature from Config_DB. @return: Return the status of auto-restart feature. """ - config_db = swsscommon.ConfigDBConnector() + config_db = swsscommon.ConfigDBConnector(use_unix_socket_path=use_unix_socket_path) config_db.connect() features_table = config_db.get_table(FEATURE_TABLE_NAME) if not features_table: @@ -122,10 +122,13 @@ def publish_events(events_handle, process_name, container_name): def main(argv): container_name = None - opts, args = getopt.getopt(argv, "c:", ["container-name="]) + use_unix_socket_path = False + opts, args = getopt.getopt(argv, "c:s", ["container-name=", "use-unix-socket-path"]) for opt, arg in opts: if opt in ("-c", "--container-name"): container_name = arg + if opt in ("-s", "--use-unix-socket-path"): + use_unix_socket_path = True if not container_name: syslog.syslog(syslog.LOG_ERR, "Container name not specified. Exiting...") @@ -159,7 +162,7 @@ def main(argv): group_name = payload_headers['groupname'] if (process_name in critical_process_list or group_name in critical_group_list) and expected == 0: - is_auto_restart = get_autorestart_state(container_name) + is_auto_restart = get_autorestart_state(container_name, use_unix_socket_path) if is_auto_restart != "disabled": MSG_FORMAT_STR = "Process '{}' exited unexpectedly. Terminating supervisor '{}'" msg = MSG_FORMAT_STR.format(payload_headers['processname'], container_name)