mirror of
https://github.com/jwinterm/nodejs-pool.git
synced 2026-10-17 05:21:27 +02:00
Send an email when not able to get last block header
This commit is contained in:
@@ -521,6 +521,30 @@ function monitorNodes() {
|
||||
});
|
||||
}
|
||||
|
||||
function monitorNodes() {
|
||||
global.coinFuncs.getLastBlockHeader((err, block) => {
|
||||
if (err !== null) {
|
||||
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.`
|
||||
);
|
||||
}
|
||||
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.`
|
||||
);
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
updateShareStats();
|
||||
updateBlockHeader();
|
||||
updatePoolStats();
|
||||
|
||||
Reference in New Issue
Block a user