MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / resolveDaemonPort

Function resolveDaemonPort

apps/kimi-code/src/cli/sub/server/daemon.ts:134–146  ·  view source on GitHub ↗
(
  host: string = DEFAULT_SERVER_HOST,
  preferred: number = DEFAULT_SERVER_PORT,
)

Source from the content-addressed store, hash-verified

132 * the server's own "port busy ⇒ +1" bind retry.
133 */
134export async function resolveDaemonPort(
135 host: string = DEFAULT_SERVER_HOST,
136 preferred: number = DEFAULT_SERVER_PORT,
137): Promise<number> {
138 for (
139 let candidate = preferred;
140 candidate < preferred + DAEMON_PORT_SCAN_LIMIT && candidate <= 65535;
141 candidate++
142 ) {
143 if (await canBind(host, candidate)) return candidate;
144 }
145 return getFreePort(host);
146}
147
148interface NodeSeaModule {
149 isSea(): boolean;

Callers 2

server.test.tsFile · 0.85
ensureDaemonFunction · 0.85

Calls 2

canBindFunction · 0.85
getFreePortFunction · 0.85

Tested by

no test coverage detected