Use database fleet registry and gate RCON polling on container readiness
This commit is contained in:
@@ -255,7 +255,7 @@ export async function komodoResolveGamePort(serverName: string): Promise<number
|
||||
|
||||
export type KomodoHealthResult =
|
||||
| { ok: true; state: string }
|
||||
| { ok: false; reason: string; snippet?: string };
|
||||
| { ok: false; reason: string; state?: string; snippet?: string };
|
||||
|
||||
// Shape-agnostic scan for the container's running-state. Walks the entire
|
||||
// payload looking for anything that resembles a state field. Covered shapes:
|
||||
@@ -290,6 +290,18 @@ export function extractContainerState(payload: unknown): string | null {
|
||||
}
|
||||
const obj = v as Record<string, unknown>;
|
||||
|
||||
// Komodo summaries expose health alongside a flat running state.
|
||||
const flatState = obj['state'] ?? obj['State'] ?? obj['status'] ?? obj['Status'];
|
||||
const flatHealth = obj['health'] ?? obj['Health'];
|
||||
const healthStatus = typeof flatHealth === 'string' ? flatHealth
|
||||
: flatHealth && typeof flatHealth === 'object'
|
||||
? ((flatHealth as Record<string, unknown>)['status'] ?? (flatHealth as Record<string, unknown>)['Status']) : null;
|
||||
if (typeof flatState === 'string' && flatState.toLowerCase() === 'running'
|
||||
&& typeof healthStatus === 'string' && healthStatus.toLowerCase() !== 'healthy') {
|
||||
found = healthStatus;
|
||||
return;
|
||||
}
|
||||
|
||||
// Docker inspect nested: { State: { Status, Running, Health: { Status } } }
|
||||
const stateObj = obj['State'];
|
||||
if (stateObj && typeof stateObj === 'object') {
|
||||
@@ -401,7 +413,7 @@ export async function komodoInspectHealthy(serverName: string): Promise<KomodoHe
|
||||
const state = extractContainerState(r.json);
|
||||
if (state) {
|
||||
const healthy = HEALTHY_STATES.has(state.toLowerCase());
|
||||
if (!healthy) return { ok: false, reason: `container state: ${state}`, snippet: r.snippet };
|
||||
if (!healthy) return { ok: false, state, reason: `container state: ${state}`, snippet: r.snippet };
|
||||
return { ok: true, state };
|
||||
}
|
||||
lastSnippet = r.snippet;
|
||||
|
||||
Reference in New Issue
Block a user