2018-10-24 21:42:33 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-12-24 01:19:08 +08:00
|
|
|
var step = require('step');
|
|
|
|
var fs = require('fs');
|
2014-08-27 00:40:58 +08:00
|
|
|
|
2019-12-24 01:19:08 +08:00
|
|
|
function HealthCheck (disableFile) {
|
2015-08-29 00:16:04 +08:00
|
|
|
this.disableFile = disableFile;
|
2014-08-27 00:40:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = HealthCheck;
|
|
|
|
|
2019-12-24 01:19:08 +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(
|
2019-12-24 01:19:08 +08:00
|
|
|
function getManualDisable () {
|
|
|
|
fs.readFile(self.disableFile, this);
|
2015-03-26 00:15:41 +08:00
|
|
|
},
|
2019-12-24 01:19:08 +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-03-26 00:15:41 +08:00
|
|
|
},
|
2019-12-24 01:19:08 +08:00
|
|
|
function handleResult (err) {
|
|
|
|
callback(err);
|
2014-08-27 00:40:58 +08:00
|
|
|
}
|
|
|
|
);
|
2015-03-26 00:15:41 +08:00
|
|
|
};
|