Files
spdm-backend/restart_all.sh

40 lines
1.4 KiB
Bash
Raw Normal View History

2025-12-11 15:07:58 +08:00
#!/bin/bash
# 定义要重启的目录顺序(与启动顺序一致)
directories=("capability" "data" "flowable" "gateway2" "pbs" "system" "task" "project")
base_dir="/home/app"
# 遍历目录并执行restart.sh
for dir in "${directories[@]}"; do
script_path="${base_dir}/${dir}/restart.sh"
# 检查脚本是否存在
if [ -f "$script_path" ]; then
echo "正在重启 ${dir} 服务..."
# 检查脚本是否可执行,如不可执行则添加执行权限
if [ ! -x "$script_path" ]; then
echo "${script_path} 添加执行权限..."
chmod +x "$script_path"
fi
# 执行重启脚本
"$script_path"
# 检查上一个命令的执行结果
if [ $? -eq 0 ]; then
echo "${dir} 服务重启成功"
else
echo "错误: ${dir} 服务重启失败,终止后续重启流程"
exit 1 # 重启失败时退出脚本,不再继续
fi
else
echo "错误: ${script_path} 不存在,终止重启流程"
exit 1 # 脚本不存在时也退出
fi
echo "----------------------------------------"
done
echo "所有服务重启成功"