Commit b3c74d6d32d5824105db20f24c0e9c7c40e2e476
1 parent
7738cafd
improve: explicit port conflict detection in start.sh
Showing
1 changed file
with
10 additions
and
3 deletions
start.sh
| @@ -14,9 +14,16 @@ if [ ! -d "node_modules" ]; then | @@ -14,9 +14,16 @@ if [ ! -d "node_modules" ]; then | ||
| 14 | exit 1 | 14 | exit 1 |
| 15 | fi | 15 | fi |
| 16 | 16 | ||
| 17 | -# 杀掉旧进程 | ||
| 18 | -lsof -ti:3000 | xargs kill -9 2>/dev/null || true | ||
| 19 | -lsof -ti:5173 | xargs kill -9 2>/dev/null || true | 17 | +# 检测并清理端口冲突 |
| 18 | +for PORT in 3000 5173; do | ||
| 19 | + PID=$(lsof -ti:$PORT 2>/dev/null || true) | ||
| 20 | + if [ -n "$PID" ]; then | ||
| 21 | + echo "⚠️ 端口 $PORT 被占用 (PID: $PID),正在释放..." | ||
| 22 | + kill -9 $PID 2>/dev/null || true | ||
| 23 | + sleep 0.5 | ||
| 24 | + echo " ✅ 端口 $PORT 已释放" | ||
| 25 | + fi | ||
| 26 | +done | ||
| 20 | 27 | ||
| 21 | # 启动后端 Agent Chat Server | 28 | # 启动后端 Agent Chat Server |
| 22 | echo "🔌 启动 Agent Server (端口 3000)..." | 29 | echo "🔌 启动 Agent Server (端口 3000)..." |