-
Notifications
You must be signed in to change notification settings - Fork 231
/
Copy pathtest.sh
63 lines (43 loc) · 1.18 KB
/
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
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# 设置工作目录为项目目录
cd ./
REPO_PATH="."
# 初始化状态变量
status=0
project="governance-retry"
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/backup" || exit
go run main.go > /dev/null 2>&1 &
client_backup_pid=$!
cd - > /dev/null || exit
# 等待 client 启动
sleep 1
# 启动 client
cd "$REPO_PATH/client/failure" || exit
go run main.go > /dev/null 2>&1 &
client_failure_pid=$!
cd - > /dev/null || exit
# 等待 client 启动
sleep 1
# 检查 server 和 client 是否仍在运行
if kill -0 $server_pid && kill -0 $client_backup_pid && kill -0 $client_failure_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_backup_pid $client_failure_pid $(lsof -t -i:8888)
# 设置脚本的退出状态
exit $status