feat: Add monitoring and automatic restart for bus provider threads
Implemented checks in `MiddlewareDaemon` to monitor the status of `bp_middleware1` and `bp_ios1` threads. Added automatic restarts for non-alive threads using `dbus_start`. Signed-off-by: Sven Sager <s.sager@kunbus.com>
This commit is contained in:
@@ -129,6 +129,17 @@ class MiddlewareDaemon:
|
|||||||
self._reconfigure = False
|
self._reconfigure = False
|
||||||
pi.startup_complete()
|
pi.startup_complete()
|
||||||
|
|
||||||
|
# Monitor bus providers for errors and restart them
|
||||||
|
restart = False
|
||||||
|
if not (self.bp_middleware1 and self.bp_middleware1.is_alive()):
|
||||||
|
log.warning("dbus middleware1 provider thread is not alive - restarting")
|
||||||
|
restart = True
|
||||||
|
if not (self.bp_ios1 and self.bp_ios1.is_alive()):
|
||||||
|
log.warning("dbus ios1 provider thread is not alive - restarting")
|
||||||
|
restart = True
|
||||||
|
if restart:
|
||||||
|
self.dbus_start()
|
||||||
|
|
||||||
# Cycle time calculation
|
# Cycle time calculation
|
||||||
dm = divmod(ot - perf_counter(), self._cycle_time)
|
dm = divmod(ot - perf_counter(), self._cycle_time)
|
||||||
# For float the result is (q, a % b), where q is usually math.floor(a / b) but may be 1 less than that.
|
# For float the result is (q, a % b), where q is usually math.floor(a / b) but may be 1 less than that.
|
||||||
|
|||||||
Reference in New Issue
Block a user