mirror of
https://github.com/myronblair/novacpx
synced 2026-06-30 17:50:41 -05:00
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:
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user