From 1720bc8ad6497bd84934ffd344096eafb6bc4003 Mon Sep 17 00:00:00 2001 From: yangdx Date: Tue, 15 Apr 2025 18:03:21 +0800 Subject: [PATCH] Do health check on page initial load --- lightrag_webui/src/App.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lightrag_webui/src/App.tsx b/lightrag_webui/src/App.tsx index 6760375c..55e6268a 100644 --- a/lightrag_webui/src/App.tsx +++ b/lightrag_webui/src/App.tsx @@ -25,6 +25,7 @@ function App() { const [apiKeyAlertOpen, setApiKeyAlertOpen] = useState(false) const [initializing, setInitializing] = useState(true) // Add initializing state const versionCheckRef = useRef(false); // Prevent duplicate calls in Vite dev mode + const healthCheckInitializedRef = useRef(false); // Prevent duplicate health checks in Vite dev mode const handleApiKeyAlertOpenChange = useCallback((open: boolean) => { setApiKeyAlertOpen(open) @@ -70,6 +71,14 @@ function App() { } }; + // On first mount or when enableHealthCheck becomes true and apiKeyAlertOpen is false, + // perform an immediate health check + if (!healthCheckInitializedRef.current) { + healthCheckInitializedRef.current = true; + // Immediate health check on first load + performHealthCheck(); + } + // Set interval for periodic execution const interval = setInterval(performHealthCheck, healthCheckInterval * 1000); return () => clearInterval(interval);