2015-03-16 07:16:36 +08:00
|
|
|
var fs = require('fs');
|
2014-11-05 22:06:01 +08:00
|
|
|
|
2015-08-28 23:41:40 +08:00
|
|
|
function HealthCheck(disableFile) {
|
|
|
|
this.disableFile = disableFile;
|
2014-11-05 22:06:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = HealthCheck;
|
|
|
|
|
|
|
|
|
2015-09-08 00:40:20 +08:00
|
|
|
HealthCheck.prototype.check = function(callback) {
|
2015-09-22 20:55:50 +08:00
|
|
|
fs.readFile(this.disableFile, function handleDisabledFile(err, data) {
|
|
|
|
var disabledError = null;
|
2015-09-22 21:15:57 +08:00
|
|
|
if (!err) {
|
|
|
|
disabledError = new Error(data || 'Unknown error');
|
2015-09-22 20:55:50 +08:00
|
|
|
disabledError.http_status = 503;
|
2014-11-05 22:06:01 +08:00
|
|
|
}
|
2015-09-22 20:55:50 +08:00
|
|
|
return callback(disabledError);
|
|
|
|
});
|
2015-01-13 18:29:19 +08:00
|
|
|
};
|