Update backend status handling and improve user notifications
- Enhanced documentation to clarify the transition from 'Idle' to 'ready (running)' for backend states, improving user understanding of system readiness. - Updated logging messages in the notification system to reflect the new backend status terminology, ensuring accurate feedback during operations. - Refined access link collection logic to better handle tunneled and non-tunneled scenarios, enhancing user experience. - Improved tests to validate the new backend status handling and ensure accurate reporting of access links and notifications.
This commit is contained in:
+29
-17
@@ -54,21 +54,24 @@ while time.time() < deadline:
|
||||
live = int(st.get("live_gens") or 0)
|
||||
loading = int(st.get("loading_models") or 0)
|
||||
bstat = str(be.get("status") or "unknown").lower()
|
||||
any_loading = bool(be.get("any_loading"))
|
||||
# SwarmUI: "running" = backends healthy & ready to generate.
|
||||
# "idle" = suspended / cannot generate. "loading" = still starting.
|
||||
if waiting or live or loading:
|
||||
print(f"BUSY queue w={waiting} live={live} load={loading}")
|
||||
elif bstat == "empty":
|
||||
# No backends registered — Comfy never installed (Install wizard).
|
||||
# Not "Idle": treat as wait, never ready.
|
||||
print("BUSY backend=empty (нужен first-install Comfy)")
|
||||
elif bstat == "loading":
|
||||
print("BUSY backend=loading (Comfy стартует, ждём Idle)")
|
||||
elif bstat in ("loading", "some_loading") or any_loading:
|
||||
print(f"BUSY backend={bstat} (Comfy стартует)")
|
||||
elif bstat == "running":
|
||||
# Self-start often reports running while still warming / first load.
|
||||
print("BUSY backend=running (Comfy прогрев, ждём Idle)")
|
||||
print("READY backend=running")
|
||||
elif bstat in ("disabled", "all_disabled"):
|
||||
print(f"BUSY backend={bstat}")
|
||||
elif bstat == "idle":
|
||||
print(f"READY backend={bstat}")
|
||||
# Suspended backends — not ready for generate; keep waiting.
|
||||
print("BUSY backend=idle (бэкенды спят, ждём running)")
|
||||
elif bstat == "errored":
|
||||
print("BUSY backend=errored")
|
||||
else:
|
||||
print(f"BUSY backend={bstat}")
|
||||
raise SystemExit(0)
|
||||
@@ -161,13 +164,22 @@ def wait_backend_idle(
|
||||
timeout: float = 2400.0,
|
||||
poll_every: float = 15.0,
|
||||
) -> None:
|
||||
"""Block until SwarmUI on the VM reports Idle backend (or timeout)."""
|
||||
"""Block until SwarmUI backends are ready (status=running, no queue).
|
||||
|
||||
Note: SwarmUI ``idle`` means suspended backends (cannot generate).
|
||||
Ready-to-use is ``running``.
|
||||
"""
|
||||
deadline = time.time() + timeout
|
||||
log(
|
||||
"жду Idle backend на VM (loading/running — норма, Comfy прогревается; "
|
||||
"ссылки :17801 — после ready + tunnel)"
|
||||
)
|
||||
log("жду ready backend (running)…")
|
||||
last = ""
|
||||
pretty = {
|
||||
"BUSY backend=loading (Comfy стартует)": "… Comfy стартует",
|
||||
"BUSY backend=some_loading (Comfy стартует)": "… Comfy стартует (часть бэкендов)",
|
||||
"BUSY backend=empty (нужен first-install Comfy)": "… backend пуст — нужен install",
|
||||
"BUSY backend=idle (бэкенды спят, ждём running)": "… бэкенды idle/спят",
|
||||
"BUSY backend=errored": "… backend errored — смотри journalctl -u swarmui",
|
||||
"READY backend=running": "backend ready (running)",
|
||||
}
|
||||
while time.time() < deadline:
|
||||
try:
|
||||
out = run_ssh(
|
||||
@@ -180,15 +192,15 @@ def wait_backend_idle(
|
||||
except Exception as exc:
|
||||
out = f"WAIT ssh: {exc}"
|
||||
line = out.splitlines()[-1] if out else "WAIT empty"
|
||||
if line != last:
|
||||
log(line)
|
||||
last = line
|
||||
shown = pretty.get(line, line)
|
||||
if shown != last:
|
||||
log(shown)
|
||||
last = shown
|
||||
if line.startswith("READY"):
|
||||
log("backend Idle")
|
||||
return
|
||||
time.sleep(poll_every)
|
||||
raise CloudError(
|
||||
f"backend не стал Idle за {int(timeout)} с. "
|
||||
f"backend не стал ready (running) за {int(timeout)} с. "
|
||||
"Проверь journalctl -u swarmui на VM; GPU всё ещё жив."
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user