File size: 8,563 Bytes
ea12399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aa41821
 
 
 
 
 
ea12399
aa41821
 
 
 
ea12399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aa41821
ea12399
 
ce5f943
 
 
 
97a2226
 
 
 
ce5f943
 
97a2226
ce5f943
97a2226
 
 
 
 
ea12399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aa41821
 
 
 
ea12399
 
aa41821
 
ea12399
 
 
 
 
 
a748f63
 
 
 
 
 
 
 
ea12399
 
 
 
 
 
 
 
 
 
 
 
 
9888be9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env bash
# ํŒŸ์—์„œ ์‹คํ–‰ํ•œ๋‹ค. tools/pod_bootstrap.py script ๊ฐ€ ๋งŒ๋“ ๋‹ค.
set -euo pipefail

COMFY_ROOT="${COMFY_ROOT:-}"
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT

# ComfyUI ๋ณธ์ฒด ๊ฒฝ๋กœ๋Š” ์ด๋ฏธ์ง€๋งˆ๋‹ค ๋‹ค๋ฅด๋‹ค(runpod/comfyui ๋Š” /workspace/runpod-slim/ComfyUI).
if [ -z "$COMFY_ROOT" ]; then
    for candidate in /workspace/ComfyUI /workspace/runpod-slim/ComfyUI /ComfyUI /root/ComfyUI /app/ComfyUI; do
        if [ -f "$candidate/main.py" ]; then COMFY_ROOT="$candidate"; break; fi
    done
fi
if [ ! -f "$COMFY_ROOT/main.py" ]; then
    echo "ComfyUI ๋ณธ์ฒด๋ฅผ ์ฐพ์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค. COMFY_ROOT=/์‹ค์ œ/๊ฒฝ๋กœ ๋กœ ์ง€์ •ํ•ด ๋‹ค์‹œ ์‹คํ–‰ํ•˜์„ธ์š”." >&2
    exit 1
fi
echo "ComfyUI: $COMFY_ROOT"

# ComfyUI ๊ฐ€ ์“ฐ๋Š” ์ธํ„ฐํ”„๋ฆฌํ„ฐ(์ด๋ฏธ์ง€์— ์ „์šฉ venv ๊ฐ€ ์žˆ๋‹ค).
# glob ์„ ls ๋กœ ํ’€๋ฉด ๋งค์น˜๊ฐ€ ์—†์„ ๋•Œ exit 2 ๊ฐ€ ๋˜๊ณ , pipefail ๋•Œ๋ฌธ์— ์กฐ์šฉํžˆ ์ฃฝ๋Š”๋‹ค.
PY=""
for candidate in "$COMFY_ROOT"/.venv*/bin/python; do
    if [ -x "$candidate" ]; then PY="$candidate"; break; fi
done
if [ -z "$PY" ]; then PY="$(command -v python3 || command -v python || true)"; fi
# hf CLI ๋Š” ์ด๋ฏธ์ง€์— ์—†์„ ์ˆ˜ ์žˆ๋‹ค. ์—†์œผ๋ฉด ๊ฐ™์€ ์ธํ„ฐํ”„๋ฆฌํ„ฐ์˜ huggingface_hub ๋กœ ๋ฐ›๋Š”๋‹ค.
HF="${HF:-}"
for candidate in "$COMFY_ROOT"/.venv*/bin/hf; do
    if [ -x "$candidate" ]; then HF="$candidate"; break; fi
done
if [ -z "$HF" ]; then HF="$(command -v hf || true)"; fi
if [ -z "$HF" ]; then echo "hf CLI ๊ฐ€ ์—†์–ด ํŒŒ์ด์ฌ API๋กœ ๋‚ด๋ ค๋ฐ›์Šต๋‹ˆ๋‹ค." >&2; fi

fetch() {
    local repo="$1" name="$2" dest="$3"
    if [ -n "$HF" ]; then
        "$HF" download "$repo" "$name" --local-dir "$dest" >/dev/null
    else
        "$PY" -c 'import sys;from huggingface_hub import hf_hub_download;hf_hub_download(sys.argv[1],sys.argv[2],local_dir=sys.argv[3])' "$repo" "$name" "$dest" >/dev/null
    fi
}

# ๋ชจ๋ธ: ๊ณต๊ฐœ ์ €์žฅ์†Œ๋ผ ํ† ํฐ์ด ํ•„์š” ์—†๋‹ค. ๋ฐ›์€ ๋’ค ์ด๋ฆ„์œผ๋กœ ์ฐพ์•„ ์ œ์ž๋ฆฌ์— ์˜ฎ๊ธด๋‹ค.
pull() {
    local repo="$1" name="$2" target="$3" src
    fetch "$repo" "$name" "$STAGE/$repo"
    src="$(find "$STAGE/$repo" -name "$name" -print -quit || true)"
    if [ -z "$src" ]; then echo "HF์— ์—†์Œ: $repo/$name" >&2; return 1; fi
    install -D -m 644 "$src" "$COMFY_ROOT/models/$target"
    # ๋นˆ ํŒŒ์ผ์ด๋ฉด ์‹คํŒจ๋กœ ๋๋‚ธ๋‹ค - ํŒŒ์ผ๋ช…๋งŒ ๋ณด๋Š” ์ ๊ฒ€์€ ์ด๊ฑธ ๋ชป ์žก๋Š”๋‹ค(์‹ค์ œ๋กœ ๋ชป ์žก์•˜๋‹ค).
    if [ ! -s "$COMFY_ROOT/models/$target" ]; then
        echo "๋‚ด๋ ค๋ฐ›๊ธฐ ์‹คํŒจ(๋นˆ ํŒŒ์ผ): $target" >&2; return 1
    fi
    # ํ•˜์œ„ ํด๋” ๋ชจ๋ธ์€ ์—ญ์Šฌ๋ž˜์‹œ ์ด๋ฆ„ ์‹ฌ๋ณผ๋ฆญ ๋งํฌ๋„ ๋งŒ๋“ ๋‹ค. ComfyUI ๋Š” ํด๋” ๋ชฉ๋ก์„
    # os.sep ๋กœ ๋งŒ๋“ค๊ธฐ ๋•Œ๋ฌธ์—(folder_paths.py) ์œˆ๋„์šฐ์—์„œ ์ €์žฅ๋œ ์›Œํฌํ”Œ๋กœ์˜
    # 'bodyparts\x' ๊ฐ’์ด ๋ฆฌ๋ˆ…์Šค ํŒŸ์—์„œ๋Š” ์–ด๋–ค ์ฝค๋ณด์™€๋„ ์•ˆ ๋งž๋Š”๋‹ค. ๋งํฌ๋ฅผ ๋งŒ๋“ค์–ด
    # ์›๋ณธ ์›Œํฌํ”Œ๋กœ๋ฅผ ๊ณ ์น˜์ง€ ์•Š๊ณ ๋„ ์–‘์ชฝ์—์„œ ๊ฐ™์€ ๊ฐ’์ด ๋งค์นญ๋˜๊ฒŒ ํ•œ๋‹ค.
    # ํ•˜์œ„ ํด๋”๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ์—๋งŒ ๋ณ„์นญ์„ ๋งŒ๋“ ๋‹ค(*/* ๋กœ ๋‘๋ฉด unet/x.gguf ์ฒ˜๋Ÿผ
    # ํด๋” ๋ฐ”๋กœ ์•„๋ž˜ ํŒŒ์ผ๋„ ๋งค์น˜๋˜์–ด ์ œ์ž๋ฆฌ๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ๋งํฌ๋กœ ์‹ค์ œ ํŒŒ์ผ์„ ์ง€์šด๋‹ค).
    case "$target" in
        */*/*)
            local root="${target%%/*}" rest="${target#*/}" win
            win="$(printf %s "$rest" | tr "/" "\\")"
            ln -sf "$rest" "$COMFY_ROOT/models/$root/$win"
            ;;
    esac
}

mkdir -p "$COMFY_ROOT/models/unet" "$COMFY_ROOT/models/vae" \
         "$COMFY_ROOT/models/text_encoders" "$COMFY_ROOT/models/loras" \
         "$COMFY_ROOT/custom_nodes"

pull bjooo/wan2.2_loras "SVI_v2_PRO_Wan2.2-I2V-A14B_HIGH_lora_rank_128_fp16.safetensors" "loras/SVI_v2_PRO_Wan2.2-I2V-A14B_HIGH_lora_rank_128_fp16.safetensors"
pull bjooo/wan2.2_loras "SVI_v2_PRO_Wan2.2-I2V-A14B_LOW_lora_rank_128_fp16.safetensors" "loras/SVI_v2_PRO_Wan2.2-I2V-A14B_LOW_lora_rank_128_fp16.safetensors"
pull bjooo/wan2.2_loras "Wan2.1_I2V_14B_FusionX_LoRA.safetensors" "loras/Wan2.1_I2V_14B_FusionX_LoRA.safetensors"
pull bjooo/wan2.2_loras "Wan_2_2_I2V_A14B_HIGH_lightx2v_4step_lora_v1030_rank_64_bf16.safetensors" "loras/Wan_2_2_I2V_A14B_HIGH_lightx2v_4step_lora_v1030_rank_64_bf16.safetensors"
pull bjooo/wan2.2_loras "Wan_2_2_I2V_A14B_LOW_lightx2v_4step_lora_260412_rank_256_fp16.safetensors" "loras/Wan_2_2_I2V_A14B_LOW_lightx2v_4step_lora_260412_rank_256_fp16.safetensors"
pull bjooo/wan2.2_loras "2.2-I2V Reveal Penis_000003000_high_noise.safetensors" "loras/bodyparts/2.2-I2V Reveal Penis_000003000_high_noise.safetensors"
pull bjooo/wan2.2_loras "2.2-I2V Reveal Penis_000003000_low_noise.safetensors" "loras/bodyparts/2.2-I2V Reveal Penis_000003000_low_noise.safetensors"
pull bjooo/wan2.2_loras "PENISLORA_22_i2v_HIGH_e320.safetensors" "loras/bodyparts/PENISLORA_22_i2v_HIGH_e320.safetensors"
pull bjooo/wan2.2_loras "PENISLORA_22_i2v_LOW_e496.safetensors" "loras/bodyparts/PENISLORA_22_i2v_LOW_e496.safetensors"
pull bjooo/wan2.2_loras "erect_penis_epoch_80.safetensors" "loras/bodyparts/erect_penis_epoch_80.safetensors"
pull bjooo/wan2.2_loras "masturbation_cumshot_v1.1_e310.safetensors" "loras/masturbation/masturbation_cumshot_v1.1_e310.safetensors"
pull bjooo/clips "nsfw_wan_umt5-xxl_fp8_scaled.safetensors" "text_encoders/nsfw_wan_umt5-xxl_fp8_scaled.safetensors"
pull bjooo/unet "Wan2.2-I2V-A14B-HighNoise-Q8_0.gguf" "unet/Wan2.2-I2V-A14B-HighNoise-Q8_0.gguf"
pull bjooo/unet "Wan2.2-I2V-A14B-LowNoise-Q8_0.gguf" "unet/Wan2.2-I2V-A14B-LowNoise-Q8_0.gguf"
pull bjooo/clips "Wan2_1_VAE_bf16.safetensors" "vae/Wan2_1_VAE_bf16.safetensors"

# ์ด๋ฏธ์ง€์— ๊ฐ™์€ ๊ณ„์—ด ํŒฉ์ด ๋“ค์–ด ์žˆ์œผ๋ฉด custom_nodes ๋ฐ–์œผ๋กœ ์˜ฎ๊ธด๋‹ค. ๋ฆฌ๋ˆ…์Šค๋Š”
# ๋Œ€์†Œ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•˜๋ฏ€๋กœ ComfyUI-KJNodes ์™€ ์šฐ๋ฆฌ comfyui-kjnodes ๊ฐ€ ๊ณต์กดํ•˜๋ฉด
# ๊ฐ™์€ ํด๋ž˜์Šค๊ฐ€ ๋‘ ๋ฒˆ ๋“ฑ๋ก๋œ๋‹ค. (.disabled ์ ‘๋ฏธ์‚ฌ๋Š” ComfyUI ๊ฐ€ ๋ฌด์‹œํ•œ๋‹ค๋Š” ๋ณด์žฅ์ด ์•ฝํ•˜๋‹ค)
mkdir -p "$COMFY_ROOT/.parked_nodes"
for collide in ComfyUI-KJNodes; do
    if [ -d "$COMFY_ROOT/custom_nodes/$collide" ]; then
        mv "$COMFY_ROOT/custom_nodes/$collide" "$COMFY_ROOT/.parked_nodes/$collide"
        echo "์ถฉ๋Œ ํŒฉ์„ ์˜ฎ๊ฒผ์Šต๋‹ˆ๋‹ค: $collide -> .parked_nodes/"
    fi
done

# ๋…ธ๋“œ: ๋กœ์ปฌ ์„ค์น˜๋ณธ ๋ฒˆ๋“ค + ํด๋ก  ๊ฐ€๋Šฅํ•œ ํŒฉ
fetch bjooo/customNode node_bundle.tar.gz "$STAGE/bundle"
tar -xzf "$STAGE/bundle/node_bundle.tar.gz" -C "$COMFY_ROOT/custom_nodes"

# ํ‚ค๋ฅผ ๋…ธ๋“œ ํด๋” .env ๋กœ๋„ ๋‚จ๊ธด๋‹ค. ํŒŸ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์žฌ์‹œ์ž‘๋˜๋ฉด(์ด๋ฏธ์ง€๊ฐ€ ๋„์šฐ๋ฏ€๋กœ)
# ์‹คํ–‰ ํ™˜๊ฒฝ๋ณ€์ˆ˜๋Š” ์ดˆ๊ธฐํ™”๋˜์ง€๋งŒ .env ๋Š” ๋ณผ๋ฅจ์— ๋‚จ๊ณ  prestartup_script.py ๊ฐ€ ์ฝ๋Š”๋‹ค.
if [ -n "${OPENROUTER_API_KEY:-}" ] && [ -d "$COMFY_ROOT/custom_nodes/dolphin_nodes" ]; then
    printf "OPENROUTER_API_KEY=%s\n" "$OPENROUTER_API_KEY" > "$COMFY_ROOT/custom_nodes/dolphin_nodes/.env"
    chmod 600 "$COMFY_ROOT/custom_nodes/dolphin_nodes/.env"
    echo "OPENROUTER_API_KEY ๋ฅผ ๋…ธ๋“œ ํด๋” .env ์— ๋‚จ๊ฒผ์Šต๋‹ˆ๋‹ค(์žฌ์‹œ์ž‘์—๋„ ์œ ์ง€)."
fi
[ -d "$COMFY_ROOT/custom_nodes/RES4LYF" ] || git clone --depth 1 https://github.com/ClownsharkBatwing/RES4LYF "$COMFY_ROOT/custom_nodes/RES4LYF"

# ํŒฉ๋ณ„ ํŒŒ์ด์ฌ ์˜์กด์„ฑ์€ ComfyUI ๊ฐ€ ์“ฐ๋Š” ์ธํ„ฐํ”„๋ฆฌํ„ฐ์— ๋„ฃ์–ด์•ผ ํ•œ๋‹ค.
for req in "$COMFY_ROOT"/custom_nodes/*/requirements.txt; do
    [ -f "$req" ] || continue
    "$PY" -m pip install -q -r "$req" || echo "์˜์กด์„ฑ ์„ค์น˜ ์‹คํŒจ: $req" >&2
done

# ๊ฐ๋… ๋…ธ๋“œ๊ฐ€ ์‹คํ–‰ ์ค‘ OpenRouter๋ฅผ ๋ถ€๋ฅธ๋‹ค. ์—†์œผ๋ฉด ๋ Œ๋”๊ฐ€ ์‹œ์ž‘ํ•˜์ž๋งˆ์ž ์ฃฝ๋Š”๋‹ค.
if [ -z "${OPENROUTER_API_KEY:-}" ]; then
    echo "๊ฒฝ๊ณ : OPENROUTER_API_KEY ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. SVI ๊ฐ๋… ๋…ธ๋“œ๊ฐ€ ์ฆ‰์‹œ ์‹คํŒจํ•ฉ๋‹ˆ๋‹ค." >&2
fi

# ์ƒˆ ๋…ธ๋“œ๋ฅผ ๋“ฑ๋กํ•˜๋ ค๋ฉด ComfyUI ํ”„๋กœ์„ธ์Šค๋งŒ ๋‹ค์‹œ ๋„์šด๋‹ค. ํŒŸ ์žฌ์‹œ์ž‘์€ ์ปจํ…Œ์ด๋„ˆ ๋””์Šคํฌ๋ฅผ
# ํ†ต์งธ๋กœ ์ดˆ๊ธฐํ™”ํ•ด์„œ ๋ฐฉ๊ธˆ ๋ฐ›์€ ๋ชจ๋ธ๊นŒ์ง€ ๋‹ค ๋‚ ์•„๊ฐ„๋‹ค(2026-09-30 ์‹ค์ธก). ์ ˆ๋Œ€ ์“ฐ์ง€ ๋ง ๊ฒƒ.
ARGS="--listen 0.0.0.0 --port 8188 --enable-cors-header"
if command -v pkill >/dev/null 2>&1; then
    pkill -f "main.py --listen" || true
    sleep 3
else
    echo "pkill ์ด ์—†์–ด ์ž๋™ ์žฌ์‹œ์ž‘์„ ๊ฑด๋„ˆ๋œ๋‹ˆ๋‹ค. ComfyUI๋ฅผ ์ง์ ‘ ์žฌ์‹œ์ž‘ํ•˜์„ธ์š”." >&2
fi
cd "$COMFY_ROOT"
nohup "$PY" main.py $ARGS > /tmp/comfyui_bootstrap.log 2>&1 &
for _ in $(seq 1 60); do
    sleep 2
    if curl -fsS -o /dev/null "http://127.0.0.1:8188/system_stats"; then
        echo "์™„๋ฃŒ. ComfyUI๊ฐ€ ์ƒˆ ๋…ธ๋“œ๋กœ ์˜ฌ๋ผ์™”์Šต๋‹ˆ๋‹ค. ์‚ฌ์ด๋“œ๋ฐ” Runpod ๋ Œ๋” ํƒญ์—์„œ ํ”„๋ฆฌํ”Œ๋ผ์ดํŠธ๋ฅผ ๋Œ๋ฆฌ์„ธ์š”."
        exit 0
    fi
done
echo "ComfyUI๊ฐ€ 2๋ถ„ ์•ˆ์— ์‘๋‹ตํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. /tmp/comfyui_bootstrap.log ๋ฅผ ํ™•์ธํ•˜์„ธ์š”." >&2
tail -20 /tmp/comfyui_bootstrap.log >&2
exit 1