MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / waitForHttp

Function waitForHttp

scripts/guardian/shared.ts:264–278  ·  view source on GitHub ↗
(url: string, opts: {
  timeoutMs: number
  intervalMs?: number
})

Source from the content-addressed store, hash-verified

262 * Alice startup on UTA `/__uta/health` being live.
263 */
264export async function waitForHttp(url: string, opts: {
265 timeoutMs: number
266 intervalMs?: number
267}): Promise<boolean> {
268 const interval = opts.intervalMs ?? 100
269 const deadline = Date.now() + opts.timeoutMs
270 while (Date.now() < deadline) {
271 try {
272 const res = await fetch(url)
273 if (res.ok) return true
274 } catch { /* not ready yet */ }
275 await sleep(interval)
276 }
277 return false
278}
279
280/** Cascade-shutdown supervisor — kills all tracked children on signal or
281 * unexpected child exit, then exits itself. Idempotent (safe to call

Callers 2

restartMethod · 0.85
mainFunction · 0.85

Calls 2

sleepFunction · 0.70
fetchFunction · 0.50

Tested by

no test coverage detected