From 8c7b93c6dd16c099a518be12682569dcbe8d9440 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Wed, 8 Feb 2023 17:00:39 -0500 Subject: [PATCH] machine: fix supervisord active state reporting Signed-off-by: Eric Callahan --- moonraker/components/machine.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/moonraker/components/machine.py b/moonraker/components/machine.py index 88ac4b8..30446fd 100644 --- a/moonraker/components/machine.py +++ b/moonraker/components/machine.py @@ -1300,13 +1300,21 @@ class SupervisordCliProvider(BaseProvider): timeout=timeout, success_codes=success_codes ) + def _get_active_state(self, sub_state: str) -> str: + if sub_state == "stopping": + return "deactivating" + elif sub_state == "running": + return "active" + else: + return "inactive" + async def _detect_active_services(self) -> None: machine: Machine = self.server.lookup_component("machine") units: Dict[str, Any] = await self._get_process_info() for unit, info in units.items(): if machine.is_service_allowed(unit): self.available_services[unit] = { - 'active_state': "active", + 'active_state': self._get_active_state(info["state"]), 'sub_state': info["state"] } @@ -1357,7 +1365,7 @@ class SupervisordCliProvider(BaseProvider): for svc, state in zip(svcs, resp_l): sub_state = state.split()[1].lower() new_state: Dict[str, str] = { - 'active_state': "active", + 'active_state': self._get_active_state(sub_state), 'sub_state': sub_state } if self.available_services[svc] != new_state: