-
Notifications
You must be signed in to change notification settings - Fork 230
/
test.sh
72 lines (50 loc) · 1.33 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
64
65
66
67
68
69
70
71
72
#!/bin/bash
# 设置工作目录为项目目录
cd ./
REPO_PATH="."
# 初始化状态变量
status=0
project="easy_note"
echo "---------------------------------------"
echo "Running project: $project"
cd "$REPO_PATH" || exit
docker-compose up -d
cd - > /dev/null || exit
# 启动 rpc note server
cd "$REPO_PATH/cmd/note" || exit
go run . > /dev/null 2>&1 &
note_server_pid=$!
cd - > /dev/null || exit
# 等待 server 启动
sleep 1
# 启动 rpc stock server
cd "$REPO_PATH/cmd/user" || exit
go run . > /dev/null 2>&1 &
user_server_pid=$!
cd - > /dev/null || exit
# 等待 server 启动
sleep 1
# 启动 hertx_server
cd "$REPO_PATH/cmd/api" || exit
go run main.go > /dev/null 2>&1 &
server_pid=$!
cd - > /dev/null || exit
# 等待 client 启动
sleep 1
# 检查 server 和 client 是否仍在运行
if kill -0 $note_server_pid && kill -0 $user_server_pid && kill -0 $server_pid; then
echo "Project run successfully: $project"
echo "---------------------------------------"
else
echo "Project failed to run: $project"
echo "---------------------------------------"
status=1
fi
# 杀死 server 和 client
kill -9 $user_server_pid $note_server_pid $server_pid $(lsof -t -i:8888)
# 停止并删除所有容器
cd "$REPO_PATH" || exit
docker-compose down
cd - > /dev/null || exit
# 设置脚本的退出状态
exit $status