#!/usr/bin/env bash # Swap GPU residency between llama-server (Qwen) and comfyui — they never # run concurrently, VRAM doesn't fit both (see issue #38's map). Manual # invocation only, no auto-switching. # # Bypasses lazytainer entirely and drives docker compose directly — its # idle-stop can't be used for this. Root cause (see # docs/research/lazytainer-omniroute-idle-stop.md, issue #40): lazytainer's # packet-threshold detector is source-blind and can't tell OmniRoute's # periodic health-check pings apart from real traffic on the same port, so # it never reliably sleeps a service on its own. A scripted swap always # knows which service should go up/down, so it doesn't need that heuristic. # # OmniRoute may show the just-stopped provider as errored/offline in its # dashboard for up to CREDENTIAL_HEALTH_CHECK_INTERVAL (default 5 min) after # a swap — cosmetic, not a functional problem (see the research doc above). set -euo pipefail cd "$(dirname "$0")/.." usage() { echo "Usage: $0 {qwen|comfyui}" >&2 echo " qwen - stop comfyui, start llama-server" >&2 echo " comfyui - stop llama-server, start comfyui" >&2 exit 1 } [ $# -eq 1 ] || usage case "$1" in qwen) from=comfyui to=llama-server ;; comfyui) from=llama-server to=comfyui ;; *) usage ;; esac echo "==> stopping $from" docker compose stop "$from" echo "==> starting $to" docker compose up -d "$to" echo "==> status" docker compose ps