This commit is contained in:
Christopher Cookman 2026-01-25 15:26:33 -07:00
parent 59e95a3a33
commit 543781439b

View file

@ -76,11 +76,13 @@ app.listen(port, () => {
// Heartbeat checks // Heartbeat checks
setInterval(() => { setInterval(() => {
const now = Date.now() / 1000; const now = Date.now() / 1000;
global.db.run('SELECT * FROM analytics WHERE heartbeatCheck <= ? AND endTime IS NULL', [now], (err, rows) => { global.db.all('SELECT * FROM analytics WHERE heartbeatCheck <= ? AND endTime IS NULL', [now], (err, rows) => {
if (err) { if (err) {
return console.error('Failed to run heartbeat check', err); return console.error('Failed to run heartbeat check', err);
} }
console.log(rows) if (rows.length === 0) {
return; // No missed heartbeats
}
rows.forEach(row => { rows.forEach(row => {
console.log(`Server ${row.id} missed heartbeat check. Marking as inactive.`); console.log(`Server ${row.id} missed heartbeat check. Marking as inactive.`);
// Set endTime to last known heartbeatCheck time, shutdownReason "missedHeartbeat" // Set endTime to last known heartbeatCheck time, shutdownReason "missedHeartbeat"