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

Method installPpidWatchdog

src/mcp/index.ts:454–473  ·  view source on GitHub ↗

* PPID watchdog (#277) — direct mode only. Daemon mode is detached on purpose * and reaps via idle timeout; proxy mode installs its own watchdog inside * runProxy. So this only ever runs for an in-process direct session.

()

Source from the content-addressed store, hash-verified

452 * {@link runProxy}. So this only ever runs for an in-process direct session.
453 */
454 private installPpidWatchdog(): void {
455 if (this.mode !== 'direct') return;
456 const pollMs = parsePpidPollMs(process.env.CODEGRAPH_PPID_POLL_MS);
457 if (pollMs <= 0) return;
458 this.ppidWatchdog = setInterval(() => {
459 const reason = supervisionLostReason({
460 originalPpid: this.originalPpid,
461 currentPpid: process.ppid,
462 hostPpid: this.hostPpid,
463 isAlive: isProcessAlive,
464 });
465 if (reason) {
466 process.stderr.write(
467 `[CodeGraph MCP] Parent process exited (${reason}); shutting down.\n`
468 );
469 this.stop();
470 }
471 }, pollMs);
472 this.ppidWatchdog.unref();
473 }
474}
475
476function sleep(ms: number): Promise<void> {

Callers 1

startDirectMethod · 0.95

Calls 4

stopMethod · 0.95
parsePpidPollMsFunction · 0.90
supervisionLostReasonFunction · 0.90
writeMethod · 0.45

Tested by

no test coverage detected