Merge pull request #282 from CartoDB/remove_per_user_check

Disable per-user healthchecks
This commit is contained in:
Raul Ochoa 2015-04-07 10:07:25 +02:00
commit 2d050eb43c
2 changed files with 2 additions and 88 deletions

View File

@ -1,6 +1,4 @@
var dot = require('dot');
var fs = require('fs'); var fs = require('fs');
var path = require('path');
var step = require('step'); var step = require('step');
function HealthCheck(metadataBackend, tilelive) { function HealthCheck(metadataBackend, tilelive) {
@ -11,24 +9,9 @@ function HealthCheck(metadataBackend, tilelive) {
module.exports = HealthCheck; module.exports = HealthCheck;
var mapnikOptions = {
query: {
metatile: 1,
poolSize: 4,
bufferSize: 64
},
protocol: 'mapnik:',
slashes: true,
xml: null
};
var xmlTemplate = dot.template(fs.readFileSync(path.resolve(__dirname, 'map-config.xml'), 'utf-8'));
HealthCheck.prototype.check = function(config, callback) { HealthCheck.prototype.check = function(config, callback) {
var self = this, var result = {
startTime,
result = {
redis: { redis: {
ok: false ok: false
}, },
@ -39,7 +22,6 @@ HealthCheck.prototype.check = function(config, callback) {
ok: false ok: false
} }
}; };
var mapnikXmlParams = config;
step( step(
function getManualDisable() { function getManualDisable() {
@ -56,50 +38,7 @@ HealthCheck.prototype.check = function(config, callback) {
throw err; throw err;
} }
}, },
function getDBParams(err) { function handleResult(err) {
if (err) {
throw err;
}
startTime = Date.now();
self.metadataBackend.getAllUserDBParams(config.username, this);
},
function loadMapnik(err, dbParams) {
if (err) {
throw err;
}
result.redis = {
ok: !err,
elapsed: Date.now() - startTime,
size: Object.keys(dbParams).length
};
mapnikOptions.xml = xmlTemplate(mapnikXmlParams);
startTime = Date.now();
self.tilelive.load(mapnikOptions, this);
},
function getTile(err, source) {
if (err) {
throw err;
}
result.mapnik = {
ok: !err,
elapsed: Date.now() - startTime
};
startTime = Date.now();
source.getTile(config.z, config.x, config.y, this);
},
function handleTile(err, tile) {
result.tile = {
ok: !err
};
if (tile) {
result.tile.elapsed = Date.now() - startTime;
result.tile.size = tile.length;
}
callback(err, result); callback(err, result);
} }
); );

View File

@ -51,31 +51,6 @@ suite('health checks', function () {
); );
}); });
test('fails for invalid user because it is not in redis', function (done) {
resetHealthConfig();
global.environment.health.username = 'invalid';
assert.response(server,
healthCheckRequest,
{
status: 503
},
function (res, err) {
assert.ok(!err);
var parsed = JSON.parse(res.body);
assert.equal(parsed.enabled, true);
assert.equal(parsed.ok, false);
assert.equal(parsed.result.redis.ok, false);
done();
}
);
});
test('error if disabled file exists', function(done) { test('error if disabled file exists', function(done) {
var fs = require('fs'); var fs = require('fs');