From bfa18725952e7bc9a18977eecfa63c6818d7cf49 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Fri, 21 Jul 2023 11:14:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=8E=B7=E5=8F=96=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run_all_server.sh | 8 +++++++- stop_all_server.sh | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/run_all_server.sh b/run_all_server.sh index cd46e711..6d8a2033 100755 --- a/run_all_server.sh +++ b/run_all_server.sh @@ -23,7 +23,13 @@ run_server() { } # 列出所有服务器目录 -server_dirs=("backend" "canteen" "data-transfer" "home-user-auth" "inventory" "map-library" "orders" "product" "product-model" "product-template" "shopping-cart-confirmation" "upload" "webset") +server_dirs=() # 初始化一个空数组 + +for dir in server/*/ ; do # 遍历 "server/" 下的所有子目录 + dir=${dir%*/} # 删除末尾的 "/" + dir=${dir##*/} # 删除开头的 "server/" + server_dirs+=("$dir") # 添加到数组 +done # 在每个服务器目录下运行相应的 go 程序 for server_dir in "${server_dirs[@]}"; do diff --git a/stop_all_server.sh b/stop_all_server.sh index 78f6fa89..1d33e4f5 100755 --- a/stop_all_server.sh +++ b/stop_all_server.sh @@ -16,7 +16,13 @@ stop_server() { } # 列出所有服务器目录 -server_dirs=("backend" "canteen" "data-transfer" "home-user-auth" "inventory" "map-library" "orders" "product" "product-model" "product-template" "shopping-cart-confirmation" "upload" "webset") +server_dirs=() # 初始化一个空数组 + +for dir in server/*/ ; do # 遍历 "server/" 下的所有子目录 + dir=${dir%*/} # 删除末尾的 "/" + dir=${dir##*/} # 删除开头的 "server/" + server_dirs+=("$dir") # 添加到数组 +done # 停止每个服务器的 screen 会话 for server_dir in "${server_dirs[@]}"; do