| 620 | } |
| 621 | |
| 622 | function _lockPayload() { |
| 623 | return JSON.stringify({ |
| 624 | pid: process.pid, |
| 625 | uid: typeof process.getuid === 'function' ? process.getuid() : null, |
| 626 | startedAt: new Date().toISOString(), |
| 627 | // Round-9: marks a daemon that refreshes this lock file's mtime on a |
| 628 | // lease (see startLockRefresh). Only when this flag is present do |
| 629 | // acquireLock / refuseHelloIfDaemonRunning trust mtime-staleness to |
| 630 | // reclaim a lock whose PID is alive -- the PID-reuse / SIGKILL-stale |
| 631 | // guard. A lock written by an OLDER daemon (no flag) keeps the legacy |
| 632 | // kill(0)-only behavior so a new binary can never falsely steal a |
| 633 | // still-running old daemon's lock (which would run two daemons). |
| 634 | lease: true, |
| 635 | }); |
| 636 | } |
| 637 | |
| 638 | // STALE_LOCK_TTL_MS / LOCK_REFRESH_MS / _lockIsStaleByLease come from |
| 639 | // src/adapters/scripts/_lockPaths.js (required next to getLockFilePath |