Merge branch 'master' into standalone-server

Conflicts:
	lib/cartodb/cartodb_windshaft.js
	lib/cartodb/monitoring/health_check.js
This commit is contained in:
Raul Ochoa 2015-09-04 13:21:54 +02:00
commit 3af2136770
2 changed files with 8 additions and 18 deletions

View File

@ -15,7 +15,7 @@ var versions = {
function ServerInfoController() { function ServerInfoController() {
this.healthConfig = global.environment.health || {}; this.healthConfig = global.environment.health || {};
this.healthCheck = new HealthCheck(); this.healthCheck = new HealthCheck(global.environment.disabled_file);
} }
module.exports = ServerInfoController; module.exports = ServerInfoController;
@ -37,13 +37,12 @@ ServerInfoController.prototype.version = function(req, res) {
ServerInfoController.prototype.health = function(req, res) { ServerInfoController.prototype.health = function(req, res) {
if (!!this.healthConfig.enabled) { if (!!this.healthConfig.enabled) {
var startTime = Date.now(); var startTime = Date.now();
this.healthCheck.check(this.healthConfig, function(err, result) { this.healthCheck.check(this.healthConfig, function(err) {
var ok = !err; var ok = !err;
var response = { var response = {
enabled: true, enabled: true,
ok: ok, ok: ok,
elapsed: Date.now() - startTime, elapsed: Date.now() - startTime
result: result
}; };
if (err) { if (err) {
response.err = err.message; response.err = err.message;

View File

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