Reduce automatic pinging

This commit is contained in:
LukeGus
2025-08-27 11:34:38 -05:00
parent a34c60947d
commit d88c890ba7
3 changed files with 33 additions and 10 deletions

View File

@@ -415,7 +415,8 @@ app.listen(PORT, async () => {
} }
}); });
setInterval(() => { // Disable automatic background polling to prevent log flooding
pollStatusesOnce().catch(err => logger.error('Background poll failed', err)); // setInterval(() => {
}, 60_000); // pollStatusesOnce().catch(err => logger.error('Background poll failed', err));
// }, 60_000);

View File

@@ -238,7 +238,7 @@ export function LeftSidebar({
React.useEffect(() => { React.useEffect(() => {
fetchHosts(); fetchHosts();
const interval = setInterval(fetchHosts, 10000); const interval = setInterval(fetchHosts, 300000); // 5 minutes instead of 10 seconds
return () => clearInterval(interval); return () => clearInterval(interval);
}, [fetchHosts]); }, [fetchHosts]);

View File

@@ -94,20 +94,23 @@ export function Server({
} }
}; };
if (currentHostConfig?.id) { if (currentHostConfig?.id && isVisible) {
fetchStatus(); fetchStatus();
fetchMetrics(); fetchMetrics();
// Only poll when component is visible to reduce unnecessary connections
intervalId = window.setInterval(() => { intervalId = window.setInterval(() => {
fetchStatus(); if (isVisible) {
fetchMetrics(); fetchStatus();
}, 10_000); fetchMetrics();
}
}, 300_000); // 5 minutes instead of 10 seconds
} }
return () => { return () => {
cancelled = true; cancelled = true;
if (intervalId) window.clearInterval(intervalId); if (intervalId) window.clearInterval(intervalId);
}; };
}, [currentHostConfig?.id]); }, [currentHostConfig?.id, isVisible]);
const topMarginPx = isTopbarOpen ? 74 : 16; const topMarginPx = isTopbarOpen ? 74 : 16;
const leftMarginPx = sidebarState === 'collapsed' ? 16 : 8; const leftMarginPx = sidebarState === 'collapsed' ? 16 : 8;
@@ -142,7 +145,26 @@ export function Server({
<StatusIndicator/> <StatusIndicator/>
</Status> </Status>
</div> </div>
<div className="flex items-center"> <div className="flex items-center gap-2">
<Button
variant="outline"
onClick={async () => {
if (currentHostConfig?.id) {
try {
const res = await getServerStatusById(currentHostConfig.id);
setServerStatus(res?.status === 'online' ? 'online' : 'offline');
const data = await getServerMetricsById(currentHostConfig.id);
setMetrics(data);
} catch {
setServerStatus('offline');
setMetrics(null);
}
}
}}
title="Refresh status and metrics"
>
Refresh
</Button>
{currentHostConfig?.enableFileManager && ( {currentHostConfig?.enableFileManager && (
<Button <Button
variant="outline" variant="outline"