fix(supervisor): pidfile lock to prevent nickname collision #9

Merged
halofourteen merged 1 commits from fix/supervisor-lockfile into main 2026-05-25 16:47:25 +03:00
halofourteen commented 2026-05-25 16:47:22 +03:00 (Migrated from github.com)

Operator launched 'npm run bot', MC server kicked every login with `Игрок с данным никнеймом уже играет на сервере`, perpetual reconnect-kick loop. Root cause: an earlier smoke-test supervisor was still alive in the background.

  • `runtime/supervisor.js` acquires `state//supervisor.pid` before spawning the child; refuses to start if another supervisor is alive. Lock released on SIGINT/SIGTERM/exit. Stale pidfiles (PID no longer alive) are detected and overwritten.
  • `scripts/stop.sh` emergency cleanup: kills supervisor + bot processes, removes pidfile + bot.sock, reminds operator to wait ~30s for the MC server to drop the session.
  • `npm run stop` script.

Smoke-test:

  • 1st supervisor → acquires lock, writes pid
  • 2nd supervisor → refuses with diagnostic message pointing at `kill ` or pidfile path
  • SIGTERM on the 1st → pidfile auto-removed

🤖 Generated with Claude Code

Operator launched 'npm run bot', MC server kicked every login with \`Игрок с данным никнеймом уже играет на сервере\`, perpetual reconnect-kick loop. Root cause: an earlier smoke-test supervisor was still alive in the background. - \`runtime/supervisor.js\` acquires \`state/<host>/supervisor.pid\` before spawning the child; refuses to start if another supervisor is alive. Lock released on SIGINT/SIGTERM/exit. Stale pidfiles (PID no longer alive) are detected and overwritten. - \`scripts/stop.sh\` emergency cleanup: kills supervisor + bot processes, removes pidfile + bot.sock, reminds operator to wait ~30s for the MC server to drop the session. - \`npm run stop\` script. Smoke-test: - 1st supervisor → acquires lock, writes pid - 2nd supervisor → refuses with diagnostic message pointing at \`kill <pid>\` or pidfile path - SIGTERM on the 1st → pidfile auto-removed 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.