MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / startPpidWatchdogNoSocket

Function startPpidWatchdogNoSocket

src/mcp/proxy.ts:627–648  ·  view source on GitHub ↗

PPID watchdog for the local-handshake proxy — same #277 logic as * startPpidWatchdog but with no socket to close (the caller's shutdown * handles teardown).

(onDeath: () => void)

Source from the content-addressed store, hash-verified

625 * {@link startPpidWatchdog} but with no socket to close (the caller's shutdown
626 * handles teardown). */
627function startPpidWatchdogNoSocket(onDeath: () => void): void {
628 const pollMs = parsePollMs(process.env.CODEGRAPH_PPID_POLL_MS);
629 if (pollMs <= 0) return;
630 // Baseline from the CLI entry's earliest capture, not process.ppid here —
631 // a launcher killed during our first ~100ms would otherwise leave the
632 // baseline at 1 and blind the divergence check forever (#1185).
633 const originalPpid = EARLY_PPID;
634 const hostPpid = parseHostPpid(process.env[HOST_PPID_ENV]);
635 const timer = setInterval(() => {
636 const reason = supervisionLostReason({
637 originalPpid,
638 currentPpid: process.ppid,
639 hostPpid,
640 isAlive: isProcessAliveLocal,
641 });
642 if (reason) {
643 process.stderr.write(`[CodeGraph MCP] Parent process exited (${reason}); shutting down.\n`);
644 onDeath();
645 }
646 }, pollMs);
647 timer.unref?.();
648}
649
650/**
651 * Read one CRLF/LF-terminated JSON line from the socket, parse it as the

Callers 1

runLocalHandshakeProxyFunction · 0.85

Calls 4

supervisionLostReasonFunction · 0.90
parsePollMsFunction · 0.85
parseHostPpidFunction · 0.70
writeMethod · 0.65

Tested by

no test coverage detected