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

Method installPpidWatchdog

src/mcp/index.ts:498–517  ·  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

496 * {@link runProxy}. So this only ever runs for an in-process direct session.
497 */
498 private installPpidWatchdog(): void {
499 if (this.mode !== 'direct') return;
500 const pollMs = parsePpidPollMs(process.env.CODEGRAPH_PPID_POLL_MS);
501 if (pollMs <= 0) return;
502 this.ppidWatchdog = setInterval(() => {
503 const reason = supervisionLostReason({
504 originalPpid: this.originalPpid,
505 currentPpid: process.ppid,
506 hostPpid: this.hostPpid,
507 isAlive: isProcessAlive,
508 });
509 if (reason) {
510 process.stderr.write(
511 `[CodeGraph MCP] Parent process exited (${reason}); shutting down.\n`
512 );
513 this.stop();
514 }
515 }, pollMs);
516 this.ppidWatchdog.unref();
517 }
518}
519
520function 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