2018-10-23 23:45:42 +08:00
|
|
|
'use strict';
|
|
|
|
|
2015-03-16 07:16:36 +08:00
|
|
|
var fs = require('fs');
|
2014-11-05 22:06:01 +08:00
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
function HealthCheck (disableFile) {
|
2015-08-28 23:41:40 +08:00
|
|
|
this.disableFile = disableFile;
|
2014-11-05 22:06:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = HealthCheck;
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
HealthCheck.prototype.check = function (callback) {
|
|
|
|
fs.readFile(this.disableFile, function handleDisabledFile (err, data) {
|
2015-09-22 20:55:50 +08:00
|
|
|
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
|
|
|
};
|