From a61cb60fc0b4f2c58e3f90dceefb4b967e6c05d2 Mon Sep 17 00:00:00 2001 From: cfdaily Date: Fri, 22 May 2026 18:35:26 +0800 Subject: [PATCH] auto-sync: 2026-05-22 18:35:26 --- scripts/reset-data.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/reset-data.sh b/scripts/reset-data.sh index a3870c0..6dae53c 100755 --- a/scripts/reset-data.sh +++ b/scripts/reset-data.sh @@ -53,6 +53,14 @@ fi echo "🛑 Stopping $PM2_NAME..." pm2 stop "$PM2_NAME" 2>/dev/null || true +# 确保 trap 恢复服务 +cleanup() { + echo "" + echo "▶️ Ensuring $PM2_NAME is running..." + pm2 restart "$PM2_NAME" 2>/dev/null || pm2 start "$PM2_NAME" 2>/dev/null || true +} +trap cleanup EXIT + # ── 清数据 ── echo "" if [ -n "$PROJECT_FILTER" ]; then @@ -81,10 +89,11 @@ echo "🗑️ Cleaning inbox and logs..." rm -f "$TARGET_DIR/inbox/"*.jsonl 2>/dev/null || true rm -f "$TARGET_DIR/logs/"* 2>/dev/null || true -# ── 重启服务 ── +# ── 重启服务 ──(trap EXIT 也会执行,但这里显式做一次) echo "" echo "▶️ Starting $PM2_NAME..." pm2 start "$PM2_NAME" +trap - EXIT # 清除 trap,避免重复执行 # ── 完成 ── echo ""