From 0a66eb00a5d6f6c72a1515a68e7b01e73d0993b7 Mon Sep 17 00:00:00 2001 From: jiankai Date: Sun, 29 Nov 2020 19:23:53 +0800 Subject: [PATCH] add the process status text for process_mngr of janus-sentinel --- januscloud/sentinel/janus_server.py | 5 +++-- januscloud/sentinel/process_mngr.py | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/januscloud/sentinel/janus_server.py b/januscloud/sentinel/janus_server.py index d1aa29a..be97203 100644 --- a/januscloud/sentinel/janus_server.py +++ b/januscloud/sentinel/janus_server.py @@ -12,7 +12,7 @@ from januscloud.proxy.core.backend_server import JANUS_SERVER_STATUS_ABNORMAL, JANUS_SERVER_STATUS_NORMAL, \ JANUS_SERVER_STATUS_MAINTENANCE, JANUS_SERVER_STATUS_HWM from januscloud.proxy.core.backend_session import BackendTransaction -from januscloud.sentinel.process_mngr import PROC_RUNNING +from januscloud.sentinel.process_mngr import PROC_RUNNING, PROC_STATUS_TEXT from januscloud.transport.ws import WSClient log = logging.getLogger(__name__) @@ -250,7 +250,8 @@ def _statistic_routine(self): self.query_stat() def on_process_status_change(self, watcher): - log.debug('on_process_status_change is called, new status: {}'.format(watcher.process_status)) + log.debug('on_process_status_change is called, new status: {}({})'.format( + watcher.process_status, PROC_STATUS_TEXT[watcher.process_status])) if watcher.process_status == PROC_RUNNING: self.start_time = time.time() else: diff --git a/januscloud/sentinel/process_mngr.py b/januscloud/sentinel/process_mngr.py index 70203ee..9af46b1 100644 --- a/januscloud/sentinel/process_mngr.py +++ b/januscloud/sentinel/process_mngr.py @@ -26,6 +26,8 @@ PROC_STOP = 0 PROC_RUNNING = 1 +PROC_STATUS_TEXT = ['STOP', 'RUNNING'] + POLL_INTERVAL_SEC = 0.1 DEFAULT_STOP_WAIT_TIMEOUT = 3 @@ -39,6 +41,7 @@ _next_wid = 0 + def _get_next_watcher_id(): global _next_wid _next_wid += 1