Do not return results from health check

It also removed old dependencies and takes disabled file path in ctor.
This commit is contained in:
Raul Ochoa 2015-08-28 17:41:40 +02:00
parent bb17609ea3
commit d6102284a4
2 changed files with 8 additions and 20 deletions

View File

@ -187,19 +187,18 @@ var CartodbWindshaft = function(serverOptions) {
* END Routing
******************************************************************************************************************/
var healthCheck = new HealthCheck(cartoData, Windshaft.tilelive);
var healthCheck = new HealthCheck(global.environment.disabled_file);
ws.get('/health', function(req, res) {
var healthConfig = global.environment.health || {};
if (!!healthConfig.enabled) {
var startTime = Date.now();
healthCheck.check(healthConfig, function(err, result) {
healthCheck.check(healthConfig, function(err) {
var ok = !err;
var response = {
enabled: true,
ok: ok,
elapsed: Date.now() - startTime,
result: result
elapsed: Date.now() - startTime
};
if (err) {
response.err = err.message;

View File

@ -1,9 +1,8 @@
var fs = require('fs');
var step = require('step');
function HealthCheck(metadataBackend, tilelive) {
this.metadataBackend = metadataBackend;
this.tilelive = tilelive;
function HealthCheck(disableFile) {
this.disableFile = disableFile;
}
module.exports = HealthCheck;
@ -11,21 +10,11 @@ module.exports = HealthCheck;
HealthCheck.prototype.check = function(config, callback) {
var result = {
redis: {
ok: false
},
mapnik: {
ok: false
},
tile: {
ok: false
}
};
var self = this;
step(
function getManualDisable() {
fs.readFile(global.environment.disabled_file, this);
fs.readFile(self.disableFile, this);
},
function handleDisabledFile(err, data) {
var next = this;
@ -39,7 +28,7 @@ HealthCheck.prototype.check = function(config, callback) {
}
},
function handleResult(err) {
callback(err, result);
return callback(err);
}
);
};