CartoDB-SQL-API/lib/monitoring/health-check.js
Daniel García Aubert 5a96dbb59c Run eslint --fix
2019-12-23 18:19:08 +01:00

35 lines
744 B
JavaScript

'use strict';
var step = require('step');
var fs = require('fs');
function HealthCheck (disableFile) {
this.disableFile = disableFile;
}
module.exports = HealthCheck;
HealthCheck.prototype.check = function (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);
}
);
};