2015-05-13 00:02:23 +08:00
|
|
|
var step = require('step'),
|
2015-03-26 00:15:41 +08:00
|
|
|
fs = require('fs');
|
2014-08-27 00:40:58 +08:00
|
|
|
|
2015-08-29 00:16:04 +08:00
|
|
|
function HealthCheck(disableFile) {
|
|
|
|
this.disableFile = disableFile;
|
2014-08-27 00:40:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = HealthCheck;
|
|
|
|
|
2015-09-08 00:34:50 +08:00
|
|
|
HealthCheck.prototype.check = function(callback) {
|
2015-08-29 00:16:04 +08:00
|
|
|
var self = this;
|
2014-08-27 00:40:58 +08:00
|
|
|
|
2015-05-13 00:02:23 +08:00
|
|
|
step(
|
2015-03-26 00:15:41 +08:00
|
|
|
function getManualDisable() {
|
2015-08-29 00:16:04 +08:00
|
|
|
fs.readFile(self.disableFile, this);
|
2015-03-26 00:15:41 +08:00
|
|
|
},
|
|
|
|
function handleDisabledFile(err, data) {
|
|
|
|
var next = this;
|
|
|
|
if (err) {
|
|
|
|
return next();
|
|
|
|
}
|
|
|
|
if (!!data) {
|
|
|
|
err = new Error(data);
|
|
|
|
err.http_status = 503;
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
},
|
2015-04-06 22:08:29 +08:00
|
|
|
function handleResult(err) {
|
2015-08-29 00:16:04 +08:00
|
|
|
callback(err);
|
2014-08-27 00:40:58 +08:00
|
|
|
}
|
|
|
|
);
|
2015-03-26 00:15:41 +08:00
|
|
|
};
|