feat: auto-healing system — HEALTHCHECK, rate-limiter cleanup, auto-rollback CI, watchdog
Deploy Staging / build (push) Failing after 14m49s

- Dockerfile: add HEALTHCHECK (30s interval, 10s timeout, 3 retries)
- rate-limit.ts: auto-cleanup stale entries every 5 min (prevents memory leak)
- scripts/auto-heal.sh: watchdog for Synology cron — auto-restarts container,
  reloads nginx gateway, escalates on excessive failures
- CI workflow: auto-rollback on deploy failure (tags :rollback image,
  reverts if health check fails after deploy)
This commit is contained in:
2026-06-28 02:52:11 +08:00
parent aac485ba30
commit 0098d9ca4a
4 changed files with 249 additions and 13 deletions
+5
View File
@@ -42,6 +42,11 @@ cd /app\n\
node ./node_modules/prisma/build/index.js db push --skip-generate --accept-data-loss 2>&1\n\
# Force 0.0.0.0 binding (Docker sets HOSTNAME to container ID)\nexport HOSTNAME=0.0.0.0\nexec node server.js\n' > /app/start.sh && chmod +x /app/start.sh
# ── Docker HEALTHCHECK ──────────────────────────────────────────
# Auto-restarts container if health endpoint fails 3 times (30s interval, 10s timeout)
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD curl -sf http://localhost:3000/mobile/api/health || exit 1
USER nextjs
EXPOSE 3000