-
Notifications
You must be signed in to change notification settings - Fork 231
/
test.sh
52 lines (36 loc) · 952 Bytes
/
test.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# 设置工作目录为项目目录
cd ./
REPO_PATH="."
# 初始化状态变量
status=0
project="middleware"
echo "---------------------------------------"
echo "Running project: $project"
# 启动 server
cd "$REPO_PATH/server" || exit
go run main.go > /dev/null 2>&1 &
server_pid=$!
cd - > /dev/null || exit
# 等待 server 启动
sleep 1
# 启动 client
cd "$REPO_PATH/client" || exit
go run main.go > /dev/null 2>&1 &
client_pid=$!
cd - > /dev/null || exit
# 等待 client 启动
sleep 1
# 检查 server 和 client 是否仍在运行
if kill -0 $server_pid && kill -0 $client_pid; then
echo "Project run successfully: $project"
echo "---------------------------------------"
else
echo "Project failed to run: $project"
echo "---------------------------------------"
status=1
fi
# 杀死 server 和 client
kill -9 $server_pid $client_pid $(lsof -t -i:8888)
# 设置脚本的退出状态
exit $status