Files
enginex-bi100-compat/entrypoint.sh

45 lines
1.6 KiB
Bash
Raw Permalink 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
# enginex-bi100-compat 入口:启动前修补 -> exec vllm serve
#
# 与社区已上线引擎 EngineX-Sunrise/enginex-S2-vllm-fix-tokenizer 同一模式
# (detect -> fix -> `exec vllm serve "$MODEL_DIR" $EXTRA "$@"`),
# 只是把「只修 tokenizer」升级成「修 tokenizer + chat_template + 架构 + 缺模块」。
#
# 平台会把 GPU 数、端口、max-model-len 等参数作为 "$@" 传进来,原样透传。
set -u
MODEL_DIR=${MODEL_DIR:-${1:-/model}}
# 若第一个参数不是目录,则认为是平台传入的 vllm 参数,MODEL_DIR 仍用默认 /model
if [ $# -gt 0 ] && [ -d "$1" ]; then
MODEL_DIR="$1"
shift
fi
FIX_LOG=/tmp/mhxc_preflight.json
echo "[entrypoint] model dir: $MODEL_DIR"
echo "[entrypoint] args: $*"
EXTRA=""
if python3 /opt/preflight.py --model "$MODEL_DIR" --out "$FIX_LOG" >/tmp/mhxc_preflight.out 2>/tmp/mhxc_preflight.err; then
# 从 JSON 里取 extra_args(用 python 解析,避免依赖 jq)
EXTRA=$(python3 - "$FIX_LOG" <<'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 as e:
print("")
PY
)
echo "[entrypoint] preflight extra args: ${EXTRA:-(无)}"
sed 's/^/[entrypoint] preflight: /' /tmp/mhxc_preflight.err 2>/dev/null || true
else
echo "[entrypoint] preflight 执行失败,按原命令继续(不阻断启动)"
sed 's/^/[entrypoint] preflight: /' /tmp/mhxc_preflight.err 2>/dev/null || true
fi
echo "[entrypoint] starting vllm..."
# shellcheck disable=SC2086
exec vllm serve "$MODEL_DIR" $EXTRA "$@"