* Start the worker-thread query pool once a default project is open (daemon * mode only; honors `CODEGRAPH_QUERY_POOL_SIZE`). Idempotent and best-effort: * if workers can't spawn on this platform the ToolHandler keeps serving reads * in-process, so the pool can only help, never break, tool
(root: string)
| 78 | * in-process, so the pool can only help, never break, tool calls. |
| 79 | */ |
| 80 | private maybeStartPool(root: string): void { |
| 81 | if (!this.opts.queryPool || this.queryPool || this.closed) return; |
| 82 | const size = resolvePoolSize(process.env.CODEGRAPH_QUERY_POOL_SIZE, os.cpus().length); |
| 83 | if (size <= 0) { |
| 84 | process.stderr.write('[CodeGraph MCP] Query pool disabled (CODEGRAPH_QUERY_POOL_SIZE=0); serving reads in-process.\n'); |
| 85 | return; |
| 86 | } |
| 87 | try { |
| 88 | this.queryPool = new QueryPool({ root, size }); |
| 89 | this.toolHandler.setQueryPool(this.queryPool); |
| 90 | process.stderr.write(`[CodeGraph MCP] Query pool: up to ${size} worker thread(s) for concurrent reads.\n`); |
| 91 | } catch (err) { |
| 92 | const msg = err instanceof Error ? err.message : String(err); |
| 93 | process.stderr.write(`[CodeGraph MCP] Query pool unavailable (${msg}); serving reads in-process.\n`); |
| 94 | this.queryPool = null; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Convenience for {@link MCPServer} compatibility: pre-seed an explicit |
no test coverage detected