mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 17:14:28 +00:00
Refactor project structure
This commit is contained in:
25
webui/src/hooks/useInstanceHealth.ts
Normal file
25
webui/src/hooks/useInstanceHealth.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
// ui/src/hooks/useInstanceHealth.ts
|
||||
import { useState, useEffect } from 'react'
|
||||
import { HealthStatus } from '@/types/instance'
|
||||
import { healthService } from '@/lib/healthService'
|
||||
|
||||
export function useInstanceHealth(instanceName: string, isRunning: boolean): HealthStatus | undefined {
|
||||
const [health, setHealth] = useState<HealthStatus | undefined>()
|
||||
|
||||
useEffect(() => {
|
||||
if (!isRunning) {
|
||||
setHealth(undefined)
|
||||
return
|
||||
}
|
||||
|
||||
// Subscribe to health updates for this instance
|
||||
const unsubscribe = healthService.subscribe(instanceName, (healthStatus) => {
|
||||
setHealth(healthStatus)
|
||||
})
|
||||
|
||||
// Cleanup subscription on unmount or when running changes
|
||||
return unsubscribe
|
||||
}, [instanceName, isRunning])
|
||||
|
||||
return health
|
||||
}
|
||||
Reference in New Issue
Block a user