MCPcopy
hub / github.com/garrytan/gstack / probeHealthWithBackoff

Function probeHealthWithBackoff

browse/src/cli.ts:251–257  ·  view source on GitHub ↗

Bounded /health probe. Returns true if the server answers within `attempts` * tries spaced `backoffMs` apart — distinguishes a busy-but-alive daemon from a * dead one (#1781) so a slow server isn't killed and restarted into a crash-loop.

(port: number, attempts = 3, backoffMs = 250)

Source from the content-addressed store, hash-verified

249 * tries spaced `backoffMs` apart — distinguishes a busy-but-alive daemon from a
250 * dead one (#1781) so a slow server isn't killed and restarted into a crash-loop. */
251async function probeHealthWithBackoff(port: number, attempts = 3, backoffMs = 250): Promise<boolean> {
252 for (let i = 0; i < attempts; i++) {
253 if (await isServerHealthy(port)) return true;
254 if (i < attempts - 1) await Bun.sleep(backoffMs);
255 }
256 return false;
257}
258
259/**
260 * Build the env for an auto-restart after a crash. headed/proxy/configHash are

Callers 1

sendCommandFunction · 0.85

Calls 1

isServerHealthyFunction · 0.85

Tested by

no test coverage detected