From 66d0257b2e3a0e4bdb02b2511881863059a1e5a5 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 11 Jan 2018 18:58:06 -0800 Subject: mpm: Enable systemd watchdog and update it from MPM - Updated systemd service file - Added health status flag in shared data object - Added thread in RPC process to update watchdog Reviewed-by: Moritz Fischer --- mpm/python/usrp_mpm/rpc_server.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'mpm/python/usrp_mpm/rpc_server.py') diff --git a/mpm/python/usrp_mpm/rpc_server.py b/mpm/python/usrp_mpm/rpc_server.py index 5e8601bbd..60de43994 100644 --- a/mpm/python/usrp_mpm/rpc_server.py +++ b/mpm/python/usrp_mpm/rpc_server.py @@ -25,6 +25,7 @@ from six import iteritems from mprpc import RPCServer from usrp_mpm.mpmlog import get_main_logger from usrp_mpm.mpmutils import to_binary_str +from usrp_mpm.sys_utils import watchdog TIMEOUT_INTERVAL = 3.0 # Seconds before claim expires TOKEN_LEN = 16 # Length of the token string @@ -81,6 +82,14 @@ class MPMServer(RPCServer): super(MPMServer, self).__init__( pack_params={'use_bin_type': True}, ) + self._state.system_ready.value = True + self.log.info("RPC server ready!") + # Optionally spawn watchdog. Note: In order for us to be able to spawn + # the task from this thread, the main process needs to hand control to + # us using watchdog.transfer_control(). + if watchdog.has_watchdog(): + self.log.info("Spawning watchdog task...") + watchdog.spawn_watchdog_task(self._state, self.log) def _init_rpc_calls(self, mgr): """ -- cgit v1.2.3