From 53c349413cc216dbb9373f5931438b8a13eb87a2 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Mon, 10 Jul 2023 13:05:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E5=8A=A8=20=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++- run_all_server.sh | 31 +++++++++++++++++++ .../etc/shopping-cart-confirmation.yaml | 2 +- stop_all_server.sh | 24 ++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100755 run_all_server.sh create mode 100755 stop_all_server.sh diff --git a/.gitignore b/.gitignore index 462bf886..a4beeba7 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,6 @@ __debug_bin .idea -.vscode \ No newline at end of file +.vscode + +screenlog.* \ No newline at end of file diff --git a/run_all_server.sh b/run_all_server.sh new file mode 100755 index 00000000..aed8cd3e --- /dev/null +++ b/run_all_server.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# 定义一个函数来在每个服务器目录下运行 go run .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 .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 \ No newline at end of file diff --git a/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml b/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml index 0203843c..be590b34 100644 --- a/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml +++ b/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml @@ -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 diff --git a/stop_all_server.sh b/stop_all_server.sh new file mode 100755 index 00000000..78f6fa89 --- /dev/null +++ b/stop_all_server.sh @@ -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