From 49047b37e4b3c1d4ab04bd72a6b3916d786dfa12 Mon Sep 17 00:00:00 2001 From: flying-hero <462087392@qq.com> Date: Sun, 5 Apr 2026 07:39:54 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20=E6=94=B9=E8=BF=9B=E6=B8=85?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=9A=E4=BD=BF=E7=94=A8=20lsof?= =?UTF-8?q?=20=E5=BC=BA=E5=88=B6=E6=B8=85=E7=90=86=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- start-dev.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/start-dev.sh b/start-dev.sh index b40e5619..5d5bba97 100755 --- a/start-dev.sh +++ b/start-dev.sh @@ -5,8 +5,21 @@ echo "🏛️ 启动龙虾议事厅开发环境..." # 检查并停止旧服务 echo "🧹 清理旧服务..." -pkill -f "meeting-room.*runserver" 2>/dev/null -pkill -f "frontend.*npm start" 2>/dev/null + +# 方法 1: 使用 lsof 查找并杀死占用端口的进程 +for port in 8000 3000; do + pid=$(lsof -t -i:$port 2>/dev/null) + if [ -n "$pid" ]; then + echo " 杀死占用端口 $port 的进程 (PID: $pid)..." + kill -9 $pid 2>/dev/null + fi +done + +# 方法 2: 使用 pkill 清理 +pkill -9 -f "manage.py runserver" 2>/dev/null +pkill -9 -f "npm start" 2>/dev/null +pkill -9 -f "node.*react-scripts" 2>/dev/null + sleep 2 # 启动后端