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