fix: wrap server_stats INSERT in try/catch — SQLite lock was killing stats API

Concurrent cron writes (collect-stats.php every 5min) caused DB lock errors
that aborted the entire stats response, leaving web/mail/FTP pages empty.
History insert is now non-fatal.
This commit is contained in:
2026-06-22 04:52:04 +00:00
parent fcde84d2ad
commit 697763f333
+7 -5
View File
@@ -390,11 +390,13 @@ BASH;
if ($active) $services[$svc] = $active;
}
// Persist to DB for history
$db->execute(
"INSERT INTO server_stats (cpu_usage,ram_usage,disk_usage,load_avg) VALUES (?,?,?,?)",
[$cpuPct, $ramPct, $diskPct, $load[0]]
);
// Persist to DB for history (non-fatal — don't let lock errors kill the stats response)
try {
$db->execute(
"INSERT INTO server_stats (cpu_usage,ram_usage,disk_usage,load_avg) VALUES (?,?,?,?)",
[$cpuPct, $ramPct, $diskPct, $load[0]]
);
} catch (Throwable $_) {}
Response::success([
'cpu' => ['pct' => $cpuPct, 'load' => $load],