diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-01-11 18:58:06 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-01-15 10:45:07 -0800 |
commit | 66d0257b2e3a0e4bdb02b2511881863059a1e5a5 (patch) | |
tree | 2ca254bbefaff30f68ac63a4397f3ea814d42f7d /mpm/python/usrp_mpm/sys_utils | |
parent | 032e483adcd0084d5479ac36c6586f7518805de3 (diff) | |
download | uhd-66d0257b2e3a0e4bdb02b2511881863059a1e5a5.tar.gz uhd-66d0257b2e3a0e4bdb02b2511881863059a1e5a5.tar.bz2 uhd-66d0257b2e3a0e4bdb02b2511881863059a1e5a5.zip |
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 <moritz.fischer@ettus.com>
Diffstat (limited to 'mpm/python/usrp_mpm/sys_utils')
-rw-r--r-- | mpm/python/usrp_mpm/sys_utils/watchdog.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/mpm/python/usrp_mpm/sys_utils/watchdog.py b/mpm/python/usrp_mpm/sys_utils/watchdog.py index 125a42c62..8f89471dc 100644 --- a/mpm/python/usrp_mpm/sys_utils/watchdog.py +++ b/mpm/python/usrp_mpm/sys_utils/watchdog.py @@ -23,14 +23,19 @@ def has_watchdog(): """ return bool(os.environ.get('WATCHDOG_USEC', False)) -def watchdog_task(shared_state, log): +def transfer_control(pid): + """ + Transfer control of watchdog notifications to new PID. + """ + daemon.notify("MAINPID={:d}".format(int(pid))) + +def _watchdog_task(shared_state, log): """ Continuously ping the watchdog to tell him that we're still alive. This will keep running until the parent thread dies, or shared_state.system_ready gets set to False by someone. """ - log.info("launching task") watchdog_timeout = \ float(os.environ.get( 'WATCHDOG_USEC', @@ -40,9 +45,12 @@ def watchdog_task(shared_state, log): daemon.notify("READY=1") log.info("READY=1, interval %f", watchdog_interval) while shared_state.system_ready.value: + # Sleep first, then ping, that avoids the case where transfer_control() + # is not yet complete before we call this for the first time, which + # would lead in error messages popping up in the systemd journal. + time.sleep(watchdog_interval) log.trace("Pinging watchdog....") daemon.notify("WATCHDOG=1") - time.sleep(watchdog_interval) log.error("Terminating watchdog thread!") return @@ -53,7 +61,7 @@ def spawn_watchdog_task(shared_state, log): outlive the main thread. """ task = threading.Thread( - target=watchdog_task, + target=_watchdog_task, args=[shared_state, log], name="MPMWatchdogTask", daemon=True, |