启动 停止脚本

This commit is contained in:
eson 2023-07-10 13:05:49 +08:00
parent 00e2d4b16b
commit 53c349413c
4 changed files with 59 additions and 2 deletions

4
.gitignore vendored
View File

@ -33,4 +33,6 @@
__debug_bin
.idea
.vscode
.vscode
screenlog.*

31
run_all_server.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
# 定义一个函数来在每个服务器目录下运行 go run <server_name>.go
run_server() {
server_name=$1
echo "Running $server_name"
# 如果之前存在相同名字的 screen 会话,先将其终止
existing_session=$(screen -ls | grep -w "$server_name")
if [ -n "$existing_session" ]; then
echo "Terminating existing screen session for $server_name"
screen -S "$server_name" -X quit
fi
# 导航到相应的目录
cd "$(dirname "$0")"/$server_name
# 使用 screen 运行 go run <server_name>.go
screen -dmS $server_name -L go run $server_name.go
# 返回到上一级目录
cd - > /dev/null
}
# 列出所有服务器目录
server_dirs=("backend" "canteen" "data-transfer" "home-user-auth" "inventory" "map-library" "orders" "product" "product-model" "product-template" "shopping-cart-confirmation" "upload" "webset")
# 在每个服务器目录下运行相应的 go 程序
for server_dir in "${server_dirs[@]}"; do
run_server $server_dir
done

View File

@ -1,6 +1,6 @@
Name: shopping-cart-confirmation
Host: 0.0.0.0
Port: 8892
Port: 9902
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth:
AccessSecret: fusen2023

24
stop_all_server.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
# 定义一个函数来停止每个服务器的 screen 会话
stop_server() {
server_name=$1
echo "Stopping $server_name"
# 如果存在具有相同名称的 screen 会话,将其终止
existing_session=$(screen -ls | grep -w "$server_name")
if [ -n "$existing_session" ]; then
echo "Terminating screen session for $server_name"
screen -S "$server_name" -X quit
else
echo "No screen session found for $server_name"
fi
}
# 列出所有服务器目录
server_dirs=("backend" "canteen" "data-transfer" "home-user-auth" "inventory" "map-library" "orders" "product" "product-model" "product-template" "shopping-cart-confirmation" "upload" "webset")
# 停止每个服务器的 screen 会话
for server_dir in "${server_dirs[@]}"; do
stop_server $server_dir
done