| 262 | * Alice startup on UTA `/__uta/health` being live. |
| 263 | */ |
| 264 | export 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 |