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

Function retryDaemon

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

Source from the content-addressed store, hash-verified

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