-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart-frontend.sh
More file actions
executable file
·38 lines (33 loc) · 991 Bytes
/
Copy pathstart-frontend.sh
File metadata and controls
executable file
·38 lines (33 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
set -e
cd "$(dirname "$0")"
check_port() {
local port=$1
local pids
pids=$(lsof -ti:"$port" 2>/dev/null) || true
if [ -n "$pids" ]; then
echo "端口 $port 已被以下进程占用:"
echo "$pids" | while read -r pid; do
echo " PID=$pid $(ps -p "$pid" -o comm= 2>/dev/null || echo '')"
done
echo -n "是否杀掉所有进程并继续?(y/n): "
read -r answer
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
echo "$pids" | while read -r pid; do
kill -9 "$pid" 2>/dev/null
done
sleep 1
echo "已释放端口 $port"
else
echo "请手动释放端口 $port 后重试"
exit 1
fi
fi
}
check_port 5173
if [ ! -d "frontend/node_modules" ]; then
echo "Installing frontend dependencies..."
npm --prefix frontend install
fi
echo "Starting frontend (Vite)..."
npm --prefix frontend run dev