From fb0db1f959987bb72deac86cf7627f22ef0da9bd Mon Sep 17 00:00:00 2001 From: MarcUs7i <96580944+MarcUs7i@users.noreply.github.com> Date: Fri, 28 Feb 2025 21:48:21 +0100 Subject: [PATCH] Refactor pulse check logic to run continuously and delay until midnight --- watcher.js | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/watcher.js b/watcher.js index 35b16eb..f1ba126 100644 --- a/watcher.js +++ b/watcher.js @@ -162,8 +162,7 @@ const checkOnionService = async (host, port) => { } }; -// Extract pulse check into a separate function -const runPulseCheck = async () => { +while(true) { config.verbose && console.log('🔄 Pulse'); let startPulse = Date.now(); let status; @@ -340,24 +339,5 @@ const runPulseCheck = async () => { console.error(e); } config.verbose && console.log('✅ Done'); -}; - -// 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); \ No newline at end of file + await delay(getMillisUntilMidnight()); +} \ No newline at end of file