MCPcopy Create free account
hub / github.com/tiann/hapi / waitForServerReady

Function waitForServerReady

cli/src/utils/autoStartServer.ts:71–87  ·  view source on GitHub ↗

* Wait for hub to become ready

(
    url: string,
    maxWaitMs: number = SERVER_STARTUP_TIMEOUT_MS,
    pollIntervalMs: number = POLL_INTERVAL_MS
)

Source from the content-addressed store, hash-verified

69 * Wait for hub to become ready
70 */
71async function waitForServerReady(
72 url: string,
73 maxWaitMs: number = SERVER_STARTUP_TIMEOUT_MS,
74 pollIntervalMs: number = POLL_INTERVAL_MS
75): Promise<boolean> {
76 const startTime = Date.now()
77
78 while (Date.now() - startTime < maxWaitMs) {
79 if (await checkServerHealth(url)) {
80 logger.debug(`[AUTO-START] Server ready after ${Date.now() - startTime}ms`)
81 return true
82 }
83 await new Promise(resolve => setTimeout(resolve, pollIntervalMs))
84 }
85
86 return false
87}
88
89/**
90 * Determine if hub should be auto-started

Callers 1

maybeAutoStartServerFunction · 0.85

Calls 2

checkServerHealthFunction · 0.85
debugMethod · 0.80

Tested by

no test coverage detected