diff --git a/start.sh b/start.sh index 844a0ce..423a7a0 100755 --- a/start.sh +++ b/start.sh @@ -14,9 +14,16 @@ if [ ! -d "node_modules" ]; then exit 1 fi -# 杀掉旧进程 -lsof -ti:3000 | xargs kill -9 2>/dev/null || true -lsof -ti:5173 | xargs kill -9 2>/dev/null || true +# 检测并清理端口冲突 +for PORT in 3000 5173; do + PID=$(lsof -ti:$PORT 2>/dev/null || true) + if [ -n "$PID" ]; then + echo "⚠️ 端口 $PORT 被占用 (PID: $PID),正在释放..." + kill -9 $PID 2>/dev/null || true + sleep 0.5 + echo " ✅ 端口 $PORT 已释放" + fi +done # 启动后端 Agent Chat Server echo "🔌 启动 Agent Server (端口 3000)..."