Spawn a foreground HTTP server (non-blocking) and return the process
(
port: number,
options: { args?: string[]; env?: Record<string, string> } = {},
)
| 2070 | |
| 2071 | /** Spawn a foreground HTTP server (non-blocking) and return the process */ |
| 2072 | function spawnHttpServer( |
| 2073 | port: number, |
| 2074 | options: { args?: string[]; env?: Record<string, string> } = {}, |
| 2075 | ): import("child_process").ChildProcess { |
| 2076 | const runner = qmdRunnerArgs([...(options.args ?? []), "mcp", "--http", "--port", String(port)]); |
| 2077 | const proc = spawn(runner.command, runner.args, { |
| 2078 | cwd: fixturesDir, |
| 2079 | env: { |
| 2080 | ...process.env, |
| 2081 | INDEX_PATH: daemonDbPath, |
| 2082 | QMD_CONFIG_DIR: daemonConfigDir, |
| 2083 | PWD: fixturesDir, |
| 2084 | ...options.env, |
| 2085 | }, |
| 2086 | stdio: ["ignore", "pipe", "pipe"], |
| 2087 | }); |
| 2088 | if (proc.pid) spawnedPids.push(proc.pid); |
| 2089 | return proc; |
| 2090 | } |
| 2091 | |
| 2092 | /** Wait for HTTP server to become ready */ |
| 2093 | async function waitForServer(port: number, timeoutMs = 5000): Promise<boolean> { |
no test coverage detected