From 644e3420dc80c0870d1c10ea685b491dd248019d Mon Sep 17 00:00:00 2001 From: Lloyd Hilaiel <lloyd@hilaiel.com> Date: Wed, 20 Jun 2012 11:30:13 +0300 Subject: [PATCH] heartbeat.check() should invoke callback with err as first param, boolean health status as second --- lib/heartbeat.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/heartbeat.js b/lib/heartbeat.js index f816a8719..e5e309fd4 100644 --- a/lib/heartbeat.js +++ b/lib/heartbeat.js @@ -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"); }); }; -- GitLab