feat(health): include degraded reasons in responses
This commit is contained in:
@@ -151,6 +151,7 @@ export class UiServer {
|
||||
const gpus = await this.gpuDetector.detectGpus();
|
||||
|
||||
let status: 'ok' | 'degraded' | 'error' = 'ok';
|
||||
const reasons = new Set<'unhealthy_container' | 'no_models_available' | 'gpu_detection_failed'>();
|
||||
const containerHealth: Record<string, 'healthy' | 'unhealthy'> = {};
|
||||
const gpuStatus: Record<string, 'available' | 'in_use' | 'error'> = {};
|
||||
|
||||
@@ -160,14 +161,21 @@ export class UiServer {
|
||||
} else {
|
||||
containerHealth[id] = 'unhealthy';
|
||||
status = 'degraded';
|
||||
reasons.add('unhealthy_container');
|
||||
}
|
||||
}
|
||||
for (const gpu of gpus) {
|
||||
gpuStatus[gpu.id] = 'available';
|
||||
}
|
||||
|
||||
if (models.size === 0) {
|
||||
status = 'degraded';
|
||||
reasons.add('no_models_available');
|
||||
}
|
||||
|
||||
const health: IHealthResponse = {
|
||||
status,
|
||||
reasons: Array.from(reasons),
|
||||
version: VERSION,
|
||||
uptime: Math.floor((Date.now() - this.startTime) / 1000),
|
||||
containers: statuses.size,
|
||||
|
||||
Reference in New Issue
Block a user