Files
enginex-bi100-compat/vllm_wrapper.sh

47 lines
1.7 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# vllm_wrapper.sh —— 拦截 vllm 二进制,启动前做兼容修补后再交给真实 vllm
#
# 设计照搬社区已上线引擎 zhengzhongwei/vLLM-Iluvatar_bi-100-opt 的做法:
# 把镜像里的 `vllm` 换成本脚本(真身改名 vllm_real),平台下发的
# `vllm serve /model --port 80 ...` 就会自然流经这里,**不需要平台改命令**。
#
# 只在 `vllm serve <目录>` 这一种形态上做修补,其余子命令原样透传。
set -u
# 与 zhengzhongwei/vLLM-Iluvatar_bi-100-opt 一致的真身路径;Dockerfile 里 vllm -> *_real
REAL=/usr/local/corex/lib64/python3/dist-packages/bin/vllm_real
PREFLIGHT=/opt/preflight.py
if [ "${1:-}" = "serve" ] && [ -n "${2:-}" ]; then
MODEL_DIR="$2"
shift 2
EXTRA=""
if [ -f "$PREFLIGHT" ]; then
# preflight 失败也绝不阻断:只打日志,按原命令跑
if python3 "$PREFLIGHT" --model "$MODEL_DIR" --out /tmp/mhxc_preflight.json \
>/tmp/mhxc_preflight.out 2>/tmp/mhxc_preflight.err; then
EXTRA=$(python3 - /tmp/mhxc_preflight.json <<'PY'
import json, sys, shlex
try:
with open(sys.argv[1], encoding="utf-8") as f:
d = json.load(f)
print(" ".join(shlex.quote(a) for a in (d.get("extra_args") or [])))
except Exception:
print("")
PY
)
else
echo "[vllm_wrapper] preflight 非 0 退出,按原命令继续"
fi
sed 's/^/[vllm_wrapper] /' /tmp/mhxc_preflight.err 2>/dev/null || true
fi
echo "[vllm_wrapper] model=$MODEL_DIR extra=${EXTRA:-(无)}"
echo "[vllm_wrapper] exec: vllm_real serve $MODEL_DIR $EXTRA $*"
# shellcheck disable=SC2086
exec "$REAL" serve "$MODEL_DIR" $EXTRA "$@"
fi
exec "$REAL" "$@"