warp / start.sh
maltose1's picture
Upload 201 files
3d87b51 verified
#!/bin/bash
# Hugging Face Spaces 启动脚本
# 同时启动 Bridge Server 和 OpenAI Compat Server
set -e
echo "===== Starting Warp2API Services ====="
# 设置环境变量
export HOST=0.0.0.0
export WARP_SERVER_PORT=7861
export OPENAI_COMPAT_PORT=7860
# 启动 Bridge Server (后台运行)
echo "Starting Bridge Server on port $WARP_SERVER_PORT..."
python server.py --port $WARP_SERVER_PORT &
BRIDGE_PID=$!
# 等待 Bridge Server 启动
echo "Waiting for Bridge Server to be ready..."
for i in {1..30}; do
if curl -s http://localhost:$WARP_SERVER_PORT/healthz > /dev/null 2>&1; then
echo "✅ Bridge Server is ready!"
break
fi
if [ $i -eq 30 ]; then
echo "❌ Bridge Server failed to start in 30 seconds"
kill $BRIDGE_PID 2>/dev/null || true
exit 1
fi
echo "Waiting... ($i/30)"
sleep 1
done
# 启动 OpenAI Compat Server (前台运行)
echo "Starting OpenAI Compat Server on port $OPENAI_COMPAT_PORT..."
python openai_compat.py --port $OPENAI_COMPAT_PORT
# 如果 OpenAI Compat Server 退出,清理 Bridge Server
kill $BRIDGE_PID 2>/dev/null || true