Add support for 'shutting_down' state in HealthBadge and health service

This commit is contained in:
2025-10-29 00:09:18 +01:00
parent 77c0e22fd0
commit c340439306
4 changed files with 16 additions and 8 deletions

View File

@@ -21,6 +21,8 @@ const HealthBadge: React.FC<HealthBadgeProps> = ({ health }) => {
return <Loader2 className="h-3 w-3 animate-spin" />; return <Loader2 className="h-3 w-3 animate-spin" />;
case "restarting": case "restarting":
return <Loader2 className="h-3 w-3 animate-spin" />; return <Loader2 className="h-3 w-3 animate-spin" />;
case "shutting_down":
return <Loader2 className="h-3 w-3 animate-spin" />;
case "stopped": case "stopped":
return <Clock className="h-3 w-3" />; return <Clock className="h-3 w-3" />;
case "failed": case "failed":
@@ -36,6 +38,8 @@ const HealthBadge: React.FC<HealthBadgeProps> = ({ health }) => {
return "outline"; return "outline";
case "restarting": case "restarting":
return "outline"; return "outline";
case "shutting_down":
return "outline";
case "stopped": case "stopped":
return "secondary"; return "secondary";
case "failed": case "failed":
@@ -51,6 +55,8 @@ const HealthBadge: React.FC<HealthBadgeProps> = ({ health }) => {
return "Starting"; return "Starting";
case "restarting": case "restarting":
return "Restarting"; return "Restarting";
case "shutting_down":
return "Shutting Down";
case "stopped": case "stopped":
return "Stopped"; return "Stopped";
case "failed": case "failed":

View File

@@ -18,7 +18,7 @@ export function useInstanceHealth(instanceName: string, instanceStatus: Instance
// Trigger health check when instance status changes to active states // Trigger health check when instance status changes to active states
useEffect(() => { useEffect(() => {
if (instanceStatus === 'running' || instanceStatus === 'restarting') { if (instanceStatus === 'running' || instanceStatus === 'restarting' || instanceStatus === 'shutting_down') {
healthService.refreshHealth(instanceName).catch(error => { healthService.refreshHealth(instanceName).catch(error => {
console.error(`Failed to refresh health for ${instanceName}:`, error) console.error(`Failed to refresh health for ${instanceName}:`, error)
}) })

View File

@@ -5,11 +5,12 @@ type HealthCallback = (health: HealthStatus) => void
// Polling intervals based on health state (in milliseconds) // Polling intervals based on health state (in milliseconds)
const POLLING_INTERVALS: Record<HealthState, number> = { const POLLING_INTERVALS: Record<HealthState, number> = {
'starting': 5000, // 5 seconds - frequent during startup 'starting': 5000, // 5 seconds - frequent during startup
'restarting': 5000, // 5 seconds - restart in progress 'restarting': 5000, // 5 seconds - restart in progress
'ready': 60000, // 60 seconds - stable state 'shutting_down': 3000, // 3 seconds - monitor shutdown progress
'stopped': 0, // No polling 'ready': 60000, // 60 seconds - stable state
'failed': 0, // No polling 'stopped': 0, // No polling
'failed': 0, // No polling
} }
class HealthService { class HealthService {
@@ -96,6 +97,7 @@ class HealthService {
case 'running': return 'starting' // Should not happen as we check HTTP for running case 'running': return 'starting' // Should not happen as we check HTTP for running
case 'failed': return 'failed' case 'failed': return 'failed'
case 'restarting': return 'restarting' case 'restarting': return 'restarting'
case 'shutting_down': return 'shutting_down'
} }
} }

View File

@@ -11,9 +11,9 @@ export const BackendType = {
export type BackendTypeValue = typeof BackendType[keyof typeof BackendType] export type BackendTypeValue = typeof BackendType[keyof typeof BackendType]
export type InstanceStatus = 'running' | 'stopped' | 'failed' | 'restarting' export type InstanceStatus = 'running' | 'stopped' | 'failed' | 'restarting' | 'shutting_down'
export type HealthState = 'stopped' | 'starting' | 'ready' | 'failed' | 'restarting' export type HealthState = 'stopped' | 'starting' | 'ready' | 'failed' | 'restarting' | 'shutting_down'
export interface HealthStatus { export interface HealthStatus {
state: HealthState state: HealthState