yangdx commited on
Commit
9b6cc31
·
1 Parent(s): a40488a

Do health check on page initial load

Browse files
Files changed (1) hide show
  1. lightrag_webui/src/App.tsx +9 -0
lightrag_webui/src/App.tsx CHANGED
@@ -25,6 +25,7 @@ function App() {
25
  const [apiKeyAlertOpen, setApiKeyAlertOpen] = useState(false)
26
  const [initializing, setInitializing] = useState(true) // Add initializing state
27
  const versionCheckRef = useRef(false); // Prevent duplicate calls in Vite dev mode
 
28
 
29
  const handleApiKeyAlertOpenChange = useCallback((open: boolean) => {
30
  setApiKeyAlertOpen(open)
@@ -70,6 +71,14 @@ function App() {
70
  }
71
  };
72
 
 
 
 
 
 
 
 
 
73
  // Set interval for periodic execution
74
  const interval = setInterval(performHealthCheck, healthCheckInterval * 1000);
75
  return () => clearInterval(interval);
 
25
  const [apiKeyAlertOpen, setApiKeyAlertOpen] = useState(false)
26
  const [initializing, setInitializing] = useState(true) // Add initializing state
27
  const versionCheckRef = useRef(false); // Prevent duplicate calls in Vite dev mode
28
+ const healthCheckInitializedRef = useRef(false); // Prevent duplicate health checks in Vite dev mode
29
 
30
  const handleApiKeyAlertOpenChange = useCallback((open: boolean) => {
31
  setApiKeyAlertOpen(open)
 
71
  }
72
  };
73
 
74
+ // On first mount or when enableHealthCheck becomes true and apiKeyAlertOpen is false,
75
+ // perform an immediate health check
76
+ if (!healthCheckInitializedRef.current) {
77
+ healthCheckInitializedRef.current = true;
78
+ // Immediate health check on first load
79
+ performHealthCheck();
80
+ }
81
+
82
  // Set interval for periodic execution
83
  const interval = setInterval(performHealthCheck, healthCheckInterval * 1000);
84
  return () => clearInterval(interval);