mirror of
https://github.com/Kizuren/statusPage.git
synced 2025-12-21 21:16:09 +01:00
Refactor pulse check logic to run continuously and delay until midnight
This commit is contained in:
parent
418166091c
commit
fb0db1f959
1 changed files with 3 additions and 23 deletions
26
watcher.js
26
watcher.js
|
|
@ -162,8 +162,7 @@ const checkOnionService = async (host, port) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extract pulse check into a separate function
|
while(true) {
|
||||||
const runPulseCheck = async () => {
|
|
||||||
config.verbose && console.log('🔄 Pulse');
|
config.verbose && console.log('🔄 Pulse');
|
||||||
let startPulse = Date.now();
|
let startPulse = Date.now();
|
||||||
let status;
|
let status;
|
||||||
|
|
@ -340,24 +339,5 @@ const runPulseCheck = async () => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
config.verbose && console.log('✅ Done');
|
config.verbose && console.log('✅ Done');
|
||||||
};
|
await delay(getMillisUntilMidnight());
|
||||||
|
}
|
||||||
// Run pulse check immediately on startup
|
|
||||||
await runPulseCheck();
|
|
||||||
|
|
||||||
// Schedule pulse check to run at midnight every day
|
|
||||||
const scheduleMidnightCheck = async () => {
|
|
||||||
const millisUntilMidnight = getMillisUntilMidnight();
|
|
||||||
await delay(millisUntilMidnight);
|
|
||||||
await runPulseCheck();
|
|
||||||
setInterval(async () => {
|
|
||||||
await runPulseCheck();
|
|
||||||
}, 24 * 60 * 60 * 1000); // 24 hours
|
|
||||||
};
|
|
||||||
|
|
||||||
scheduleMidnightCheck();
|
|
||||||
|
|
||||||
// Regular interval checks
|
|
||||||
setInterval(async () => {
|
|
||||||
await runPulseCheck();
|
|
||||||
}, config.interval);
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue