Enhance backend management and diagnostics in install_swarm_comfy.py

- Introduced a new `delete_backend` function to facilitate backend removal during recovery processes.
- Improved the `recover_errored_backends` function to handle backend reconfiguration and recreation more effectively, including enhanced logging for diagnostics.
- Added a new `add_comfy_selfstart` function to streamline the addition of new backends.
- Updated the `comfy_start_script` function to prefer absolute paths for better reliability.
- Enhanced diagnostics in `swarm_diag.py` to include detailed backend settings and mount status.
- Added tests to validate the new backend management features and ensure robust error handling.
This commit is contained in:
Leonid Pershin
2026-08-21 11:12:20 +03:00
parent a18074c985
commit d3d689052d
3 changed files with 203 additions and 32 deletions
+12
View File
@@ -97,6 +97,14 @@ def swarm_api_bits() -> str:
"current_model": val.get("current_model"),
}
chunks.append("ListBackends=" + json.dumps(summary, ensure_ascii=False, indent=2))
# Full settings for first backend (StartScript path matters)
for key, val in (backends or {}).items():
if isinstance(val, dict) and val.get("settings"):
chunks.append(
f"backend[{key}].settings="
+ json.dumps(val.get("settings"), ensure_ascii=False)
)
break
except Exception as exc:
chunks.append(f"ListBackends fail: {exc}")
except Exception as exc:
@@ -109,10 +117,14 @@ def paths_bits() -> str:
f"DATA={DATA} exists={DATA.is_dir()}",
f"dlbackend={DLBACKEND} exists={DLBACKEND.is_dir()}",
f"ComfyUI={COMFY} exists={COMFY.is_dir()}",
f"main.py={(COMFY / 'main.py')} exists={(COMFY / 'main.py').is_file()}",
f"venv_python={VENV_PY} exists={VENV_PY.is_file()} exec={os.access(VENV_PY, os.X_OK) if VENV_PY.is_file() else False}",
f"opt_dlbackend_main={Path('/opt/swarmui/dlbackend/ComfyUI/main.py')} "
f"exists={Path('/opt/swarmui/dlbackend/ComfyUI/main.py').is_file()}",
f"Settings.fds exists={SETTINGS.is_file()}",
f"Backends.fds exists={BACKENDS_FDS.is_file()}",
]
rows.append("findmnt /opt/swarmui/dlbackend:\n" + _run(["findmnt", "/opt/swarmui/dlbackend"]))
if SETTINGS.is_file():
try:
for line in SETTINGS.read_text(encoding="utf-8", errors="replace").splitlines():