MCPcopy Create free account
hub / github.com/MathMan05/Fermi / checkHealth

Function checkHealth

src/stats.ts:121–138  ·  view source on GitHub ↗
(instance: Instance, api: string, tries = 0)

Source from the content-addressed store, hash-verified

119}
120
121async function checkHealth(instance: Instance, api: string, tries = 0): Promise<void> {
122 try {
123 const response = await fetch(`${api}/ping`, {method: "HEAD"});
124 console.log(`Checking health for ${instance.name}: ${response.status}`);
125 if (response.ok || tries > 3) {
126 setStatus(instance, response.ok);
127 } else {
128 retryHealthCheck(instance, api, tries);
129 }
130 } catch (error) {
131 console.error(`Error checking health for ${instance.name}:`, error);
132 if (tries > 3) {
133 setStatus(instance, false);
134 } else {
135 retryHealthCheck(instance, api, tries);
136 }
137 }
138}
139
140function retryHealthCheck(instance: Instance, api: string, tries: number): void {
141 setTimeout(() => checkHealth(instance, api, tries + 1), 30000);

Callers 3

resolveInstanceFunction · 0.85
scheduleHealthCheckFunction · 0.85
retryHealthCheckFunction · 0.85

Calls 3

setStatusFunction · 0.85
retryHealthCheckFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected