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

Function retryDaemon

src/mcp/proxy.ts:524–547  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

522 retryTimer.unref?.();
523 };
524 const retryDaemon = async (): Promise<void> => {
525 if (shuttingDown || daemonStatus !== 'failed') return;
526 // While a writing engine owns writer.pid no daemon can start (#2277). Hand
527 // the lock back first, once the calls it is serving have answered, and
528 // buffer new calls until a daemon answers or we resume in-process. One
529 // writer at a time: the engine is fully stopped before a daemon is spawned.
530 const handover = engine !== null && !engine.isReadOnly();
531 if (handover) {
532 daemonStatus = 'connecting';
533 await retireEngine();
534 }
535 const socket = await connectDaemon();
536 if (shuttingDown) return;
537 if (socket) {
538 process.stderr.write('[CodeGraph MCP] Shared daemon reachable; proxying this session to it instead of serving in-process.\n');
539 attachDaemon(socket, true);
540 // A read-only engine holds no lock: let its calls finish, then close it.
541 if (!handover) void retireEngine();
542 return;
543 }
544 daemonStatus = 'failed';
545 serveBufferedLocally();
546 scheduleDaemonRetry();
547 };
548
549 const attachDaemon = (socket: net.Socket, replayInitialize: boolean): void => {
550 daemonSocket = socket;

Callers 1

scheduleDaemonRetryFunction · 0.85

Calls 7

retireEngineFunction · 0.85
connectDaemonFunction · 0.85
attachDaemonFunction · 0.85
serveBufferedLocallyFunction · 0.85
scheduleDaemonRetryFunction · 0.85
isReadOnlyMethod · 0.80
writeMethod · 0.65

Tested by

no test coverage detected