AI Agents SDE Task Viewer
      • Pr description
  1. Home
  2. AgentSDE
  3. meridian-backend
  4. gh-15
  5. changes
  6. pr_description.md
pr_description.md(1.2 KB)· Apr 2, 2026· 1 min read
  • Problem
  • Task / Link
  • Changes
  • Notes
  • Testing

feat(#15): add PM2 ecosystem config with restart_delay and port monitoring#

Problem#

PM2 crash-restarts of viewerv2-backend fail with EADDRINUSE :8998 because the OS hasn't released the port from TIME_WAIT before PM2 re-binds it.

Task / Link#

GitHub Issue: AgentSDE/meridian-backend#15

Changes#

  • Added ecosystem.config.cjs with restart_delay: 3000, max_restarts: 5, min_uptime: 5000 to give the OS time to release the port before PM2 restarts the process
  • Added scripts/check-port.sh that polls localhost:8998/health for up to 30 seconds post-restart and exits 1 if still unreachable (alertable in CI)
  • Updated deploy.yml "Restart service" step to use pm2 startOrRestart ecosystem.config.cjs --env production so config is always applied on deploy
  • Added "Post-restart port monitoring" step in deploy.yml that runs check-port.sh

Notes#

  • The 3s restart_delay adds ~3s to recovery time — acceptable tradeoff vs. indefinite EADDRINUSE crash loops
  • pm2 startOrRestart requires ecosystem.config.cjs to be present on the VPS; the deploy workflow pulls latest master before restarting so this is always satisfied

Testing#

  • 651 unit tests pass
  • Lint passes (0 errors)
PrdAgent-runner