#!/bin/bash LOGFILE="/tmp/startup.log" exec > >(tee -a "$LOGFILE") 2>&1 echo "=== QwenV19 startup at $(date) ===" # --- 1. Patch ReActor NSFW filter --- REACTOR_NODES="/workspace/ComfyUI/custom_nodes/ComfyUI-ReActor/nodes.py" if [ -f "$REACTOR_NODES" ]; then if grep -q "if not sfw.nsfw_image" "$REACTOR_NODES"; then echo "[PATCH] Disabling ReActor NSFW filter..." sed -i 's/if not sfw.nsfw_image(img_byte_arr, NSFWDET_MODEL_PATH):/if True: # NSFW check disabled/' "$REACTOR_NODES" echo "[OK] ReActor NSFW filter disabled" else echo "[OK] ReActor NSFW filter already patched" fi fi # --- 2. Install deps (fresh container may be missing them) --- echo "[DEPS] Installing ComfyUI requirements..." pip install -r /workspace/ComfyUI/requirements.txt -q 2>&1 | tail -3 pip install insightface onnxruntime-gpu -q 2>&1 | tail -3 if [ -f /workspace/ComfyUI/custom_nodes/ComfyUI-ReActor/requirements.txt ]; then pip install -r /workspace/ComfyUI/custom_nodes/ComfyUI-ReActor/requirements.txt -q 2>&1 | tail -3 fi echo "[OK] Dependencies installed" # --- 3. Start ComfyUI --- if pgrep -f "ComfyUI/main.py" > /dev/null; then echo "[OK] ComfyUI already running (PID: $(pgrep -f 'ComfyUI/main.py'))" else echo "[START] Launching ComfyUI..." nohup python3 /workspace/ComfyUI/main.py --listen 0.0.0.0 --port 8188 > /tmp/comfyui.log 2>&1 & echo "[OK] ComfyUI started (PID: $!)" for i in $(seq 1 30); do if curl -s http://localhost:8188/api/system_stats > /dev/null 2>&1; then echo "[OK] ComfyUI responding on port 8188" break fi sleep 2 done fi echo "ComfyUI PID: $(pgrep -f 'ComfyUI/main.py' || echo 'NOT RUNNING')" echo "ComfyUI log: /tmp/comfyui.log"