Files
serverAppConfigs/dankclaw/comfyui/comfyui-healthcheck.py
T
Frank 03d44d3308 comfyui: replace the stale compose container with a Quadlet unit
ComfyUI had failed 9,146 times and had been down ~7 hours when this was found:
its container was created 2026-09-15 14:12, BEFORE the GPU declarations were
added to the compose service, and `restart: unless-stopped` kept restarting
that stale container — no /dev/kfd, no /dev/dri, no keep-groups — so it died
every time on `RuntimeError: No HIP GPUs are available`. Its "unit" was a
hand-written ~/.config/systemd/user/comfyui.service that shelled out to
`podman compose up -d`, which is not repo-tracked state and collides by name
with the Quadlet the generator produces.

  - dankclaw/comfyui/quadlet/comfyui.container: image comfyui-rocm:gfx1151
    (built from Containerfile.comfyui), /dev/kfd + /dev/dri, keep-groups,
    the four comfyui-data volumes, loopback-only publish (an unguarded service
    is internal-only here; the homepage card probes 127.0.0.1:8188), Restart=
    always, WantedBy=default.target.
  - the compose service is deleted — one owner per container name.
  - deploy_comfyui builds the image, installs the unit, retires the compose-era
    unit into ~/.AGENTTRASH, removes the stale container so the unit's own can
    take the name, and waits on :8188.
  - the healthcheck is a file, because the podman 5.x v1 generator splits
    HealthCmd on spaces and an inline `python3 -c "..."` becomes a quoting
    puzzle that fails silently.

The comfyui seam now reads the unit instead of compose for devices, command and
groups (and resolves the Containerfile from the deployer's declaration, not
from a directory listing).
2026-09-16 07:13:27 -07:00

22 lines
852 B
Python
Executable File

#!/usr/bin/env python3
"""ComfyUI container healthcheck: the UI must answer on :8188.
Runs INSIDE the container, where the UI listens (the unit publishes that port on
the host loopback for the homepage status card). ComfyUI only answers once
torch, the custom nodes and the graph are loaded, so a 200 here means the
service is usable rather than merely a live process — the distinction that
matters, because the failure this replaced was a container that stayed "up"
while dying on every start.
HealthCmd in the quadlet splits on spaces into an argv array (podman 5.x v1
generator), which is why this is a file and not an inline `python3 -c`.
"""
import sys
import urllib.request
try:
with urllib.request.urlopen("http://127.0.0.1:8188/", timeout=10) as resp:
sys.exit(0 if resp.status == 200 else 1)
except Exception:
sys.exit(1)