From 774a5254cc4f57a26a8e450e17886935709c2190 Mon Sep 17 00:00:00 2001 From: adaxi Date: Sun, 18 Feb 2018 22:33:23 +0100 Subject: [PATCH] Avoid spamming the administrator when the daemon is stuck. --- lib/worker.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 0723bc0..1a0e545 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -504,13 +504,27 @@ function updateWalletStats() { } +let lastBlockCheckIsOk = true; function monitorNodes() { global.coinFuncs.getLastBlockHeader((err, block) => { if (err !== null) { - return global.support.sendEmail( + if (lastBlockCheckIsOk) { + lastBlockCheckIsOk = false; + global.support.sendEmail( + global.config.general.adminEmail, + 'Failed to query daemon for last block header', + `The worker failed to return last block header. Please verify if the daemon is running properly.` + ); + } + return + } + if (!lastBlockCheckIsOk) { + lastBlockCheckIsOk = true; + global.support.sendEmail( global.config.general.adminEmail, - 'Failed to query daemon for last block header', - `The worker failed to return last block header. Please verify if the daemon is running properly.` + 'Quering daemon for last block header is back to normal', + `An warning was sent to you indicating that the the worker failed to return the last block header. + The issue seems to be solved now.` ); } const sql = 'SELECT blockID, hostname, ip FROM pools WHERE last_checkin > DATE_SUB(NOW(), INTERVAL 30 MINUTE)'; @@ -525,6 +539,7 @@ function monitorNodes() { } }) }); + }); }