Windshaft-cartodb/lib/monitoring/health-check.js

21 lines
499 B
JavaScript
Raw Normal View History

'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) {
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) {
var disabledError = null;
if (!err) {
disabledError = new Error(data || 'Unknown error');
disabledError.http_status = 503;
2014-11-05 22:06:01 +08:00
}
return callback(disabledError);
});
};