#!/usr/bin/env sh set -e # 启动后端(很多项目默认监听 :3001) /app/gpt-load & APP_PID=$! # 如果 HF 注入的 $PORT 不是 3001,用 socat 转发 $PORT -> 3001 if [ "${PORT:-7860}" != "3001" ]; then echo "Forwarding :$PORT -> :3001 via socat" socat TCP-LISTEN:${PORT},fork,reuseaddr TCP:127.0.0.1:3001 & fi # 等待后端进程 wait $APP_PID