diff --git a/package.json b/package.json index 4128897..7ac0daf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodeguard", - "version": "0.5.5", + "version": "0.5.6", "description": "Conceal Node Guard", "main": "index.js", "scripts": { diff --git a/units/comms.js b/units/comms.js index 5aee92f..0315109 100644 --- a/units/comms.js +++ b/units/comms.js @@ -18,6 +18,7 @@ module.exports = { var lastTS = moment(); this.stop = function () { + clearInterval(checkInterval); IsRunning = false; }; @@ -36,11 +37,6 @@ module.exports = { }, 30000); }; - function reportError(reason) { - clearInterval(checkInterval); - errorCallback(reason); - } - function checkAliveAndWell() { if (IsRunning) { CCXApi.info().then(data => { @@ -55,14 +51,14 @@ module.exports = { var duration = moment.duration(moment().diff(lastTS)); if (duration.asSeconds() > (configOpts.restart.maxBlockTime || 1800)) { - reportError(vsprintf("No new block has be seen for more then %d minutes", [(configOpts.restart.maxBlockTime || 1800) / 60])); + errorCallback(vsprintf("No new block has be seen for more then %d minutes", [(configOpts.restart.maxBlockTime || 1800) / 60])); heightIsOK = false; } } if (heightIsOK) { if (data.status !== "OK") { - reportError("Status is: " + data.status); + errorCallback("Status is: " + data.status); } else { // reset counter timeoutCount = 0; @@ -72,7 +68,7 @@ module.exports = { if (IsRunning) { timeoutCount++; if (timeoutCount >= 3) { - reportError(err); + errorCallback(err); } } }); diff --git a/units/engine.js b/units/engine.js index 6153cbd..56f4024 100644 --- a/units/engine.js +++ b/units/engine.js @@ -27,7 +27,6 @@ exports.NodeGuard = function (cmdOptions, configOpts, rootPath, guardVersion) { var starupTime = moment(); var errorCount = 0; var isStoping = false; - var initChecking = false; var initInterval = null; var poolInterval = null; var locationData = null; @@ -171,9 +170,8 @@ exports.NodeGuard = function (cmdOptions, configOpts, rootPath, guardVersion) { // periodically check if the core has initialized //*************************************************************// function waitForCoreToInitialize() { - if (!initialized && !initChecking) { + if (!initialized) { var duration = moment.duration(moment().diff(starupTime)); - initChecking = true; if (duration.asSeconds() > (configOpts.restart.maxInitTime || 900)) { restartDaemonProcess("Initialization is taking to long, restarting", true); @@ -181,11 +179,9 @@ exports.NodeGuard = function (cmdOptions, configOpts, rootPath, guardVersion) { request.get({ url: `http://127.0.0.1:${configOpts.node.port}/getinfo`, headers: { 'User-Agent': 'Conceal Node Guardian' }, - timeout: 3000, + timeout: 5000, json: true }, (err, res, release) => { - initChecking = false; - if ((!err) && (res.body.status === "OK")) { logMessage("Core is initialized, starting the periodic checking...", "info", false); clearInterval(initInterval); @@ -265,7 +261,7 @@ exports.NodeGuard = function (cmdOptions, configOpts, rootPath, guardVersion) { // start the initilize checking initInterval = setInterval(function () { waitForCoreToInitialize(); - }, 5000); + }, 10000); } }