mirror of
https://github.com/jwinterm/nodejs-pool.git
synced 2026-12-04 12:13:59 +01:00
Merge pull request #322 from keyhash/feature/send-email-on-rpc-error
Send an email when the worker cannot get the last block header
This commit is contained in:
+32
-10
@@ -504,20 +504,42 @@ function updateWalletStats() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let lastBlockCheckIsOk = true;
|
||||||
function monitorNodes() {
|
function monitorNodes() {
|
||||||
global.mysql.query("SELECT blockID, hostname, ip FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) {
|
global.coinFuncs.getLastBlockHeader((err, block) => {
|
||||||
global.coinFuncs.getLastBlockHeader(function (err, block) {
|
if (err !== null) {
|
||||||
if (err !== null){
|
if (lastBlockCheckIsOk) {
|
||||||
console.error("Issue in getting block header. Skipping node monitor");
|
lastBlockCheckIsOk = false;
|
||||||
return;
|
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.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
rows.forEach(function (row) {
|
return
|
||||||
if (row.blockID < block.height - 3) {
|
}
|
||||||
global.support.sendEmail(global.config.general.adminEmail, "Pool server behind in blocks", "The pool server: "+row.hostname+" with IP: "+row.ip+" is "+(block.height - row.blockID)+ " blocks behind");
|
if (!lastBlockCheckIsOk) {
|
||||||
}
|
lastBlockCheckIsOk = true;
|
||||||
}
|
global.support.sendEmail(
|
||||||
|
global.config.general.adminEmail,
|
||||||
|
'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)';
|
||||||
|
global.mysql.query(sql).then(pools => {
|
||||||
|
pools.forEach(({ blockID, hostname, ip }) => {
|
||||||
|
if (blockID < block.height - 3) {
|
||||||
|
global.support.sendEmail(
|
||||||
|
global.config.general.adminEmail,
|
||||||
|
'Pool server is behind in blocks',
|
||||||
|
`The pool server: ${hostname} with IP: ${ip} is ${(block.height - blockID)} blocks behind.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user