From 4ea8d6bc9a61d87470d25a5f08c0e7f237d5b346 Mon Sep 17 00:00:00 2001 From: Sven Sager Date: Fri, 6 Feb 2026 18:23:55 +0100 Subject: [PATCH] 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 --- src/revpi_middleware/daemon.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/revpi_middleware/daemon.py b/src/revpi_middleware/daemon.py index 202090b..06e3dc8 100644 --- a/src/revpi_middleware/daemon.py +++ b/src/revpi_middleware/daemon.py @@ -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.