Enhance backend idle management and diagnostics in SwarmUI
- Updated the `wait_backend_idle` function to handle disabled backends, introducing a new failure condition and diagnostics collection for better error handling. - Refactored the `install_swarm_comfy` script to include a new `configure_comfy_backend` function, streamlining backend configuration and enabling better management of backend states. - Added tests to validate the new functionality for handling disabled backends and ensuring robust diagnostics, improving overall backend management.
This commit is contained in:
+18
-1
@@ -207,21 +207,25 @@ def wait_backend_idle(
|
||||
timeout: float = 2400.0,
|
||||
poll_every: float = 15.0,
|
||||
errored_fail_sec: float = 120.0,
|
||||
disabled_fail_sec: float = 90.0,
|
||||
) -> None:
|
||||
"""Block until SwarmUI backends are ready (status=running, no queue).
|
||||
|
||||
Note: SwarmUI ``idle`` means suspended backends (cannot generate).
|
||||
Ready-to-use is ``running``. Sustained ``errored`` fail-fasts (won't self-heal).
|
||||
Ready-to-use is ``running``. Sustained ``errored`` / ``disabled`` fail-fasts.
|
||||
"""
|
||||
deadline = time.time() + timeout
|
||||
log("жду ready backend (running)…")
|
||||
last = ""
|
||||
errored_since: float | None = None
|
||||
disabled_since: float | None = None
|
||||
pretty = {
|
||||
"BUSY backend=loading (Comfy стартует)": "… Comfy стартует",
|
||||
"BUSY backend=some_loading (Comfy стартует)": "… Comfy стартует (часть бэкендов)",
|
||||
"BUSY backend=empty (нужен first-install Comfy)": "… backend пуст — нужен install",
|
||||
"BUSY backend=errored": "… backend errored — смотри journalctl -u swarmui",
|
||||
"BUSY backend=disabled": "… backend disabled (пустой StartScript?)",
|
||||
"BUSY backend=all_disabled": "… все backends disabled",
|
||||
"READY backend=running": "backend ready (running)",
|
||||
"READY backend=idle (backends present, suspended)": "backend ready (idle/suspended)",
|
||||
}
|
||||
@@ -256,6 +260,19 @@ def wait_backend_idle(
|
||||
)
|
||||
else:
|
||||
errored_since = None
|
||||
if "BUSY backend=disabled" in line or "BUSY backend=all_disabled" in line:
|
||||
now = time.time()
|
||||
if disabled_since is None:
|
||||
disabled_since = now
|
||||
elif now - disabled_since >= disabled_fail_sec:
|
||||
collect_swarm_diagnostics(cfg, host, log)
|
||||
raise CloudError(
|
||||
f"backend=disabled уже {int(now - disabled_since)} с — "
|
||||
"обычно пустой StartScript (нужен dlbackend/ComfyUI/main.py). "
|
||||
"Диагностика выше. Server → Backends → Edit StartScript или re-run up."
|
||||
)
|
||||
else:
|
||||
disabled_since = None
|
||||
time.sleep(poll_every)
|
||||
collect_swarm_diagnostics(cfg, host, log)
|
||||
raise CloudError(
|
||||
|
||||
Reference in New Issue
Block a user