exefg commited on
Commit
b3b7039
·
verified ·
1 Parent(s): cbd8d26

harden bootstrap-h3.sh

Browse files
Files changed (1) hide show
  1. bootstrap-h3.sh +18 -11
bootstrap-h3.sh CHANGED
@@ -2,27 +2,33 @@
2
  # Remote worker bootstrap for hypium-h3-prod-v1.
3
  # Official RunPod PyTorch image + HF-hosted worker source. Weights come from
4
  # RunPod --model-reference, never from this Mac.
5
- set -euo pipefail
6
  export DEBIAN_FRONTEND=noninteractive
 
7
  SRC_URL="${H3_WORKER_SRC_URL:-https://huggingface.co/datasets/exefg/hypium-worker-src/resolve/main/h3-src.tgz}"
8
  COMFY_PIN="${H3_COMFY_PIN:-12d5279438bfefc058a269eae805ceab6047777f}"
 
 
 
 
 
9
 
10
  if [[ ! -f /opt/hypium/worker/handler.py ]]; then
11
- apt-get update
12
- apt-get install -y --no-install-recommends git ffmpeg ca-certificates curl
13
  mkdir -p /opt/hypium
14
- curl -fsSL "$SRC_URL" -o /tmp/h3-src.tgz
15
- tar -xzf /tmp/h3-src.tgz -C /opt/hypium
16
- pip install --no-cache-dir --break-system-packages -r /opt/hypium/worker/requirements.txt
17
- pip install --no-cache-dir --break-system-packages --ignore-installed cryptography runpod==1.10.1
18
  fi
19
 
20
  if [[ ! -d /opt/ComfyUI ]]; then
21
- git clone --depth 1 --branch v0.34.0 https://github.com/comfyanonymous/ComfyUI.git /opt/ComfyUI
22
  cd /opt/ComfyUI
23
  git fetch --depth 1 origin "$COMFY_PIN" || true
24
- git checkout "$COMFY_PIN"
25
- pip install --no-cache-dir --break-system-packages -r requirements.txt
26
  fi
27
 
28
  export WORKSPACE_DIR="${WORKSPACE_DIR:-/opt/hypium/worker}"
@@ -30,5 +36,6 @@ export COMFYUI_PATH="${COMFYUI_PATH:-/opt/ComfyUI}"
30
  export COMFYUI_MODELS="${COMFYUI_MODELS:-/opt/ComfyUI/models}"
31
  export PYTHONPATH=/opt/hypium/worker
32
  export MODE_TO_RUN=serverless
33
- chmod +x /opt/hypium/worker/start.sh
 
34
  exec /opt/hypium/worker/start.sh
 
2
  # Remote worker bootstrap for hypium-h3-prod-v1.
3
  # Official RunPod PyTorch image + HF-hosted worker source. Weights come from
4
  # RunPod --model-reference, never from this Mac.
5
+ set -uo pipefail
6
  export DEBIAN_FRONTEND=noninteractive
7
+ export PYTHONUNBUFFERED=1
8
  SRC_URL="${H3_WORKER_SRC_URL:-https://huggingface.co/datasets/exefg/hypium-worker-src/resolve/main/h3-src.tgz}"
9
  COMFY_PIN="${H3_COMFY_PIN:-12d5279438bfefc058a269eae805ceab6047777f}"
10
+ log() { echo "{\"event\":\"h3_boot\",\"msg\":\"$*\"}"; }
11
+ fail() { echo "{\"event\":\"h3_boot_failed\",\"msg\":\"$*\"}"; sleep 3600; exit 1; }
12
+
13
+ log "python=$(command -v python3 || true) $(python3 --version 2>/dev/null || true)"
14
+ df -h / | tail -1 || true
15
 
16
  if [[ ! -f /opt/hypium/worker/handler.py ]]; then
17
+ apt-get update || fail "apt-get update"
18
+ apt-get install -y --no-install-recommends git ffmpeg ca-certificates curl || fail "apt-get install"
19
  mkdir -p /opt/hypium
20
+ curl -fL --retry 5 "$SRC_URL" -o /tmp/h3-src.tgz || fail "download h3-src.tgz"
21
+ tar -xzf /tmp/h3-src.tgz -C /opt/hypium || fail "extract h3-src.tgz"
22
+ pip install --no-cache-dir --break-system-packages -r /opt/hypium/worker/requirements.txt || fail "pip worker reqs"
23
+ pip install --no-cache-dir --break-system-packages --ignore-installed cryptography runpod==1.10.1 || fail "pip runpod"
24
  fi
25
 
26
  if [[ ! -d /opt/ComfyUI ]]; then
27
+ git clone --depth 1 --branch v0.34.0 https://github.com/comfyanonymous/ComfyUI.git /opt/ComfyUI || fail "clone ComfyUI"
28
  cd /opt/ComfyUI
29
  git fetch --depth 1 origin "$COMFY_PIN" || true
30
+ git checkout "$COMFY_PIN" || fail "checkout Comfy pin"
31
+ pip install --no-cache-dir --break-system-packages -r requirements.txt || fail "pip Comfy reqs"
32
  fi
33
 
34
  export WORKSPACE_DIR="${WORKSPACE_DIR:-/opt/hypium/worker}"
 
36
  export COMFYUI_MODELS="${COMFYUI_MODELS:-/opt/ComfyUI/models}"
37
  export PYTHONPATH=/opt/hypium/worker
38
  export MODE_TO_RUN=serverless
39
+ chmod +x /opt/hypium/worker/start.sh || fail "chmod start.sh"
40
+ log "starting start.sh"
41
  exec /opt/hypium/worker/start.sh