-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·40 lines (37 loc) · 860 Bytes
/
run.sh
File metadata and controls
executable file
·40 lines (37 loc) · 860 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
39
40
#!/bin/bash
# 用法: ./run.sh build|run
set -e
if [ "$1" = "build" ]; then
echo "==== 构建前端 ===="
cd frontend
npm install
npm run build
cd ..
echo "==== 构建后端 ===="
cd backend
cargo build --release
cd ..
echo "==== 构建完成 ===="
elif [ "$1" = "run" ]; then
echo "==== 启动后端 ===="
cd backend
cargo run &
BACKEND_PID=$!
cd ..
echo "==== 启动前端 ===="
cd frontend
npm run dev &
FRONTEND_PID=$!
cd ..
echo "前端和后端已启动。"
echo "后端PID: $BACKEND_PID, 前端PID: $FRONTEND_PID"
wait $BACKEND_PID $FRONTEND_PID
elif [ "$1" = "clean" ]; then
rm -rf backend/target
rm -rf frontend/node_modules
rm -rf frontend/dist
echo "clean 项目依赖和构建文件 "
else
echo "用法: $0 build|run"
exit 1
fi