GitLab CI
Deploy commit 3c8509d5 via GitLab CI
3750f59
Raw History Blame Contribute Delete
1.94 kB
#!/bin/bash
# One-shot warmup (supervisord program, autorestart=false):
# waits for all three services to be healthy, then sends a tiny request to each
# vLLM instance so the models are hot in VRAM before the first user request.
set -u
PORT_OCR="${PORT_OCR:-8001}"
PORT_VLM="${PORT_VLM:-8002}"
LAYOUT_PORT="${LAYOUT_PORT:-8003}"
SERVED_OCR="${SERVED_OCR:-glm-ocr}"
SERVED_VLM="${SERVED_VLM:-qwen3-vl}"
wait_http() {
local url="$1" max="${2:-240}" i=0
until curl -sf "$url" >/dev/null 2>&1; do
i=$((i + 1))
if [ "$i" -ge "$max" ]; then
echo "[warmup] TIMEOUT waiting for $url"
return 1
fi
sleep 5
done
echo "[warmup] $url is ready"
return 0
}
echo "[warmup] Waiting for vllm-ocr on :${PORT_OCR} (model load can take several minutes)..."
wait_http "http://127.0.0.1:${PORT_OCR}/health" 240 || exit 1
echo "[warmup] Waiting for vllm-vlm on :${PORT_VLM}..."
wait_http "http://127.0.0.1:${PORT_VLM}/health" 240 || exit 1
echo "[warmup] Waiting for layout service on :${LAYOUT_PORT}..."
wait_http "http://127.0.0.1:${LAYOUT_PORT}/health" 120 || exit 1
echo "[warmup] Sending warmup request to ${SERVED_OCR}..."
curl -s -m 600 -X POST "http://127.0.0.1:${PORT_OCR}/v1/chat/completions" \
-H 'Content-Type: application/json' \
-d "{\"model\":\"${SERVED_OCR}\",\"messages\":[{\"role\":\"user\",\"content\":\"Hi\"}],\"max_tokens\":8}" \
>/dev/null || echo "[warmup] WARNING: OCR warmup request failed (first request will be slower)"
echo "[warmup] Sending warmup request to ${SERVED_VLM}..."
curl -s -m 600 -X POST "http://127.0.0.1:${PORT_VLM}/v1/chat/completions" \
-H 'Content-Type: application/json' \
-d "{\"model\":\"${SERVED_VLM}\",\"messages\":[{\"role\":\"user\",\"content\":\"Hi\"}],\"max_tokens\":8}" \
>/dev/null || echo "[warmup] WARNING: VLM warmup request failed (first request will be slower)"
echo "[warmup] Done."
exit 0