From 64e488fa497abb68b645886c4b1dec287d03b4d5 Mon Sep 17 00:00:00 2001 From: Hanashi Date: Thu, 6 Aug 2026 03:04:28 -0400 Subject: [PATCH] start-comfyui: nohup fallback when tmux unavailable; parameterize port-forward Co-Authored-By: Claude Fable 5 --- scripts/local/port-forward.sh | 12 +++++++----- scripts/pod/start-comfyui.sh | 17 +++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/scripts/local/port-forward.sh b/scripts/local/port-forward.sh index 31125b6..c28745a 100755 --- a/scripts/local/port-forward.sh +++ b/scripts/local/port-forward.sh @@ -1,11 +1,13 @@ #!/bin/bash -# Persistent port forward: localhost:8188 -> pod ComfyUI. +# Persistent port forward: localhost:$LOCAL_PORT -> pod ComfyUI (8188). # Auto-reconnects if the tunnel drops. Ctrl-C to stop. -# Requires the echelon key loaded in your ssh agent. -POD_HOST=216.243.220.136 -POD_PORT=17561 +# Defaults to the B200 pod; override for others, e.g. the RTX 4090: +# POD_HOST=213.173.102.163 POD_PORT=20497 LOCAL_PORT=8189 port-forward.sh +POD_HOST=${POD_HOST:-216.243.220.136} +POD_PORT=${POD_PORT:-17561} +LOCAL_PORT=${LOCAL_PORT:-8188} while true; do - ssh -N -L 8188:127.0.0.1:8188 \ + ssh -N -L "$LOCAL_PORT":127.0.0.1:8188 \ -o ServerAliveInterval=30 -o ServerAliveCountMax=3 \ -o ExitOnForwardFailure=yes \ -o StrictHostKeyChecking=accept-new \ diff --git a/scripts/pod/start-comfyui.sh b/scripts/pod/start-comfyui.sh index 2288f0d..f921e46 100755 --- a/scripts/pod/start-comfyui.sh +++ b/scripts/pod/start-comfyui.sh @@ -1,16 +1,21 @@ #!/bin/bash -# Start ComfyUI headless on the pod inside tmux, listening on 127.0.0.1:8188. +# Start ComfyUI headless on the pod, listening on 127.0.0.1:8188. +# Uses tmux when available (attachable session), else nohup. # Access from your laptop via scripts/local/port-forward.sh set -euo pipefail -SESSION=comfyui LOG=/workspace/minimax-h3/comfyui.log -if tmux has-session -t "$SESSION" 2>/dev/null; then - echo "ComfyUI tmux session already running" +if pgrep -f "python3? main.py" >/dev/null; then + echo "ComfyUI already running" exit 0 fi -tmux new -s "$SESSION" -d \ - "cd /ComfyUI && python main.py --listen 127.0.0.1 --port 8188 2>&1 | tee -a $LOG" +if command -v tmux >/dev/null; then + tmux new -s comfyui -d \ + "cd /ComfyUI && python3 main.py --listen 127.0.0.1 --port 8188 2>&1 | tee -a $LOG" +else + cd /ComfyUI + nohup python3 main.py --listen 127.0.0.1 --port 8188 >>"$LOG" 2>&1 & +fi echo "started; tail $LOG"