diff --git a/deploy.sh b/deploy.sh index bca3589..ce00c16 100755 --- a/deploy.sh +++ b/deploy.sh @@ -167,7 +167,9 @@ cleanup_old_versions() { # 重启服务 + 验证 restart_and_verify() { log "重启 ${APP_NAME} 服务..." - if systemctl list-unit-files 2>/dev/null | grep -q "^${APP_NAME}.service"; then + # 注意:不要用 "list-unit-files | grep -q"——grep -q 提前退出会让 systemctl 收到 + # SIGPIPE,在 pipefail 下整条管道判假(unit 多的机器必踩),误报"服务不存在" + if systemctl cat "${APP_NAME}" >/dev/null 2>&1; then $SUDO systemctl restart "${APP_NAME}" $SUDO systemctl enable "${APP_NAME}" >/dev/null 2>&1 || true else