Skip to content
Snippets Groups Projects
Commit 644e3420 authored by Lloyd Hilaiel's avatar Lloyd Hilaiel
Browse files

heartbeat.check() should invoke callback with err as first param, boolean health status as second

parent b2ec9af1
No related branches found
No related tags found
No related merge requests found
......@@ -35,10 +35,10 @@ exports.setup = function(app, options, cb) {
// callback for checking a dependency
function checkCB (num) {
return function (isOk, reason) {
return function (err, isOk) {
checked++;
if (!isOk) {
notOk.push(dependencies[num] + ': '+ reason);
if (err) {
notOk.push(dependencies[num] + ': '+ err);
}
// if all dependencies have been checked
......@@ -102,16 +102,16 @@ var check = exports.check = function(url, cb) {
path: exports.path
}, function (res) {
clearTimeout(timeoutHandle);
if (res.statusCode === 200) cb(true);
if (res.statusCode === 200) cb(null, true);
else {
logger.warn("heartbeat failure: non-200 response from " + shortname + ". fatal! (" +
res.statusCode + ")");
cb(false, "response code " + res.statusCode);
cb("response code " + res.statusCode);
}
});
req.on('error', function (e) {
clearTimeout(timeoutHandle);
logger.warn("heartbeat failure: can't communicate with " + shortname + ". fatal: " + e);
cb(false, e);
cb(e ? e : "unknown error");
});
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment