gdfgdf
This commit is contained in:
@@ -335,6 +335,22 @@ async function fetchModelId(api: string): Promise<string> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Wartet nach einem Server-Neustart (503/Verbindungsfehler), bis /health
|
||||||
|
* wieder OK meldet — Modell-Reload dauert 1-2 Minuten. */
|
||||||
|
async function waitForHealthy(api: string, timeoutMs: number): Promise<void> {
|
||||||
|
const healthUrl = api.replace(/\/v1\/?$/, "") + "/health";
|
||||||
|
const deadline = Date.now() + timeoutMs;
|
||||||
|
while (Date.now() < deadline) {
|
||||||
|
try {
|
||||||
|
const r = await fetch(healthUrl, { signal: AbortSignal.timeout(5000) });
|
||||||
|
if (r.ok) return;
|
||||||
|
} catch {
|
||||||
|
/* Server noch weg */
|
||||||
|
}
|
||||||
|
await new Promise((res) => setTimeout(res, 5000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function callVision(api: string, images: string[], timeoutMs: number): Promise<VisionRaw> {
|
async function callVision(api: string, images: string[], timeoutMs: number): Promise<VisionRaw> {
|
||||||
const content: Array<Record<string, unknown>> = [{ type: "text", text: USER_PROMPT }];
|
const content: Array<Record<string, unknown>> = [{ type: "text", text: USER_PROMPT }];
|
||||||
for (const img of images) {
|
for (const img of images) {
|
||||||
@@ -512,7 +528,15 @@ async function main(): Promise<void> {
|
|||||||
break;
|
break;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
lastErr = e instanceof Error ? e.message : String(e);
|
lastErr = e instanceof Error ? e.message : String(e);
|
||||||
if (attempt < RETRIES) await new Promise((res) => setTimeout(res, 5000 * attempt));
|
if (attempt < RETRIES) {
|
||||||
|
if (/HTTP 50[23]|fetch failed|aborted|ECONNREFUSED|ECONNRESET/i.test(lastErr)) {
|
||||||
|
// Server crasht/lädt neu → auf /health warten (Modell-Reload dauert)
|
||||||
|
progress(`${tag} … Server neu am Laden, warte auf /health`);
|
||||||
|
await waitForHealthy(args.api, 300_000);
|
||||||
|
} else {
|
||||||
|
await new Promise((res) => setTimeout(res, 5000 * attempt));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user