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:
Sven Sager
2026-02-06 18:23:55 +01:00
parent fdaf7b3ac6
commit 4ea8d6bc9a

View File

@@ -129,6 +129,17 @@ class MiddlewareDaemon:
self._reconfigure = False
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
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.