CartoDB-SQL-API/app/monitoring/health_check.js

35 lines
713 B
JavaScript
Raw Normal View History

2023-05-19 00:42:48 +08:00
'use strict';
var step = require('step'),
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);
}
);
};