MCPcopy
hub / github.com/colbymchenry/codegraph / installPpidWatchdog

Method installPpidWatchdog

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

424 * {@link runProxy}. So this only ever runs for an in-process direct session.
425 */
426 private installPpidWatchdog(): void {
427 if (this.mode !== 'direct') return;
428 const pollMs = parsePpidPollMs(process.env.CODEGRAPH_PPID_POLL_MS);
429 if (pollMs <= 0) return;
430 this.ppidWatchdog = setInterval(() => {
431 const reason = supervisionLostReason({
432 originalPpid: this.originalPpid,
433 currentPpid: process.ppid,
434 hostPpid: this.hostPpid,
435 isAlive: isProcessAlive,
436 });
437 if (reason) {
438 process.stderr.write(
439 `[CodeGraph MCP] Parent process exited (${reason}); shutting down.\n`
440 );
441 this.stop();
442 }
443 }, pollMs);
444 this.ppidWatchdog.unref();
445 }
446}
447
448function 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