c6c614b5bf
It also removed old dependencies and takes disabled file path in ctor.
33 lines
715 B
JavaScript
33 lines
715 B
JavaScript
var step = require('step'),
|
|
fs = require('fs');
|
|
|
|
function HealthCheck(disableFile) {
|
|
this.disableFile = disableFile;
|
|
}
|
|
|
|
module.exports = HealthCheck;
|
|
|
|
HealthCheck.prototype.check = function(username, query, callback) {
|
|
var self = this;
|
|
|
|
step(
|
|
function getManualDisable() {
|
|
fs.readFile(self.disableFile, this);
|
|
},
|
|
function handleDisabledFile(err, data) {
|
|
var next = this;
|
|
if (err) {
|
|
return next();
|
|
}
|
|
if (!!data) {
|
|
err = new Error(data);
|
|
err.http_status = 503;
|
|
throw err;
|
|
}
|
|
},
|
|
function handleResult(err) {
|
|
callback(err);
|
|
}
|
|
);
|
|
};
|