MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / waitForServerReady

Function waitForServerReady

src/cm/lsp/serverLauncher.ts:199–215  ·  view source on GitHub ↗

* Wait for the server ready signal (when axs prints "listening on"). * The axs proxy writes the port file immediately after binding, then prints the message. * So once the signal is received, the port file should be available.

(
  serverId: string,
  timeout = 10000,
)

Source from the content-addressed store, hash-verified

197 * So once the signal is received, the port file should be available.
198 */
199async function waitForServerReady(
200 serverId: string,
201 timeout = 10000,
202): Promise<boolean> {
203 const deadline = Date.now() + timeout;
204 const pollInterval = 50;
205
206 while (Date.now() < deadline) {
207 if (serverReadySignals.has(serverId)) {
208 serverReadySignals.delete(serverId);
209 return true;
210 }
211 await sleep(pollInterval);
212 }
213
214 return false;
215}
216
217/**
218 * Wait for the port file to be available after server signals ready.

Callers 1

waitForPortFunction · 0.85

Calls 2

sleepFunction · 0.85
deleteMethod · 0.65

Tested by

no test coverage detected