Merge branch 'standalone-server' into standalone-server-mvt

This commit is contained in:
Raul Ochoa 2015-09-18 17:23:58 +02:00
commit 0d3e96ee9f
17 changed files with 19 additions and 45 deletions

4
app.js
View File

@ -87,9 +87,9 @@ var server = cartodbWindshaft(serverOptions);
// 128 is a good number if you have up to 1024 filedescriptors
// 4 is good if you have max 32 filedescriptors
// 1 is good if you have max 16 filedescriptors
server.maxConnections = global.environment.maxConnections || 128;
var backlog = global.environment.maxConnections || 128;
var listener = server.listen(serverOptions.bind.port, serverOptions.bind.host);
var listener = server.listen(serverOptions.bind.port, serverOptions.bind.host, backlog);
var version = require("./package").version;

View File

@ -1,5 +1,6 @@
var assert = require('assert');
var crypto = require('crypto');
var debug = require('debug')('windshaft:templates');
var step = require('step');
var _ = require('underscore');
var dot = require('dot');
@ -327,7 +328,7 @@ o.updTemplate = function(owner, tpl_id, template, callback) {
function handleTemplateUpdate(err, didSetNewField) {
assert.ifError(err);
if (didSetNewField) {
console.warn('New template created on update operation');
debug('New template created on update operation');
}
return true;
},

View File

@ -72,7 +72,6 @@ BaseController.prototype.req2params = function(req, callback){
if ( req.params.token ) {
// Token might match the following patterns:
// - {user}@{tpl_id}@{token}:{cache_buster}
//console.log("Request parameters include token " + req.params.token);
var tksplit = req.params.token.split(':');
req.params.token = tksplit[0];
if ( tksplit.length > 1 ) {
@ -97,7 +96,6 @@ BaseController.prototype.req2params = function(req, callback){
/*var template_hash = */tksplit.shift(); // unused
}
req.params.token = tksplit.shift();
//console.log("Request for token " + req.params.token + " with signature from " + req.params.signer);
}
}

View File

@ -116,12 +116,6 @@ LayergroupController.prototype.tileOrLayer = function (req, res) {
function mapController$finalize(err, tile, headers, stats) {
req.profiler.add(stats);
self.finalizeGetTileOrGrid(err, req, res, tile, headers);
return null;
},
function finish(err) {
if ( err ) {
console.error("windshaft.tiles: " + err);
}
}
);
};
@ -241,7 +235,7 @@ LayergroupController.prototype.sendResponse = function(req, res, body, status, h
function sendResponse(err, affectedTables) {
req.profiler.done('affectedTables');
if (err) {
console.log('ERROR generating cache channel: ' + err);
global.logger.warn('ERROR generating cache channel: ' + err);
}
if (!!affectedTables) {
var tablesCacheEntry = new TablesCacheEntry(dbName, affectedTables);

View File

@ -264,7 +264,7 @@ MapController.prototype.afterLayergroupCreate = function(req, res, mapconfig, la
req.profiler.done('incMapviewCount');
}
if ( err ) {
console.log("ERROR: failed to increment mapview count for user '" + username + "': " + err);
global.logger.log("ERROR: failed to increment mapview count for user '" + username + "': " + err);
}
done();
});

View File

@ -48,7 +48,7 @@ NamedMapsController.prototype.sendResponse = function(req, res, resource, header
function sendResponse(err, result) {
req.profiler.done('affectedTables');
if (err) {
console.log('ERROR generating cache channel: ' + err);
global.logger.log('ERROR generating cache channel: ' + err);
}
if (!result || !!result.affectedTables) {
// we increase cache control as we can invalidate it

View File

@ -14,12 +14,11 @@ CdbRequest.prototype.userByReq = function(req) {
}
var mat = host.match(this.RE_USER_FROM_HOST);
if ( ! mat ) {
console.error("Pattern '" + this.RE_USER_FROM_HOST + "' does not match hostname '" + host + "'");
global.logger.error("Pattern '%s' does not match hostname '%s'", this.RE_USER_FROM_HOST, host);
return;
}
// console.log("Matches: "); console.dir(mat);
if ( mat.length !== 2 ) {
console.error("Pattern '" + this.RE_USER_FROM_HOST + "' gave unexpected matches against '" + host + "': ", mat);
global.logger.error("Pattern '%s' gave unexpected matches against '%s': %s", this.RE_USER_FROM_HOST, host, mat);
return;
}
return mat[1];

View File

@ -78,9 +78,9 @@ module.exports = function(serverOptions) {
error: !!err ? JSON.stringify(err.message) : undefined
});
if (err) {
console.warn(logMessage);
global.logger.warn(logMessage);
} else {
console.info(logMessage);
global.logger.info(logMessage);
}
});
}

View File

@ -40,7 +40,6 @@ module.exports = {
if (count > 1) {
debug("last statsd client socket error repeated " + count + " times");
instance.last_error.count = 1;
//console.log("Clearing interval");
clearInterval(instance.last_error.interval);
instance.last_error.interval = null;
}

View File

@ -70,7 +70,6 @@ function rendererCacheErrorListener() {
}
function gcTimingListener(gcTime) {
console.log('gctime');
global.statsClient.timing('windshaft.rendercache.gc', gcTime);
}

View File

@ -174,7 +174,6 @@ suite(suiteName, function() {
var errors = [];
if ( err ) {
errors.push(err.message);
console.log("Error: " + err);
}
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
if ( err ) {
@ -278,7 +277,6 @@ suite(suiteName, function() {
var errors = [];
if ( err ) {
errors.push(err.message);
console.log("Error: " + err);
}
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
if ( err ) {
@ -500,7 +498,6 @@ suite(suiteName, function() {
var errors = [];
if ( err ) {
errors.push(err.message);
console.log("Error: " + err);
}
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
if ( err ) {
@ -831,7 +828,6 @@ suite(suiteName, function() {
var errors = [];
if ( err ) {
errors.push(err.message);
console.log("Error: " + err);
}
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
if ( err ) {
@ -950,7 +946,6 @@ suite(suiteName, function() {
var errors = [];
if ( err ) {
errors.push(err.message);
console.log("Error: " + err);
}
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
if ( err ) {
@ -1114,7 +1109,6 @@ suite(suiteName, function() {
var errors = [];
if ( err ) {
errors.push(err.message);
console.log("Error: " + err);
}
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
if ( err ) {
@ -1219,7 +1213,6 @@ suite(suiteName, function() {
function finish(err) {
if ( err ) {
errors.push(err.message);
console.log("Error: " + err);
}
if ( errors.length ) {
done(new Error(errors));

View File

@ -139,8 +139,6 @@ describe('named static maps', function() {
}
};
console.log(url);
var statusCode = options.status || 200;
var expectedResponse = {

View File

@ -41,7 +41,6 @@ describe('multilayer', function() {
fs.readFile(filename, "binary", function(err, file) {
if ( err ) {
response.writeHead(404, {'Content-Type': 'text/plain'});
console.log("File '" + filename + "' not found");
response.write("404 Not Found\n");
} else {
response.writeHead(200);
@ -499,7 +498,6 @@ describe('multilayer', function() {
},
function do_get_tile(err)
{
console.log(err);
assert.ifError(err);
var next = this;
assert.response(server, {
@ -742,7 +740,6 @@ describe('multilayer', function() {
return null;
},
function finish(err) {
//if ( err ) console.log(err.stack);
var errors = [];
if ( err ) {
errors.push(''+err);

View File

@ -201,10 +201,8 @@ describe('server_gettile', function() {
};
var test_strict_lbl = "unused directives are not tolerated if strict";
if ( semver.satisfies(mapnik.versions.mapnik, '2.3.x') ) {
// Strictness handling changed in 2.3.x, possibly a bug:
// see http://github.com/mapnik/mapnik/issues/2301
console.warn("Strictness test skipped due to http://github.com/mapnik/mapnik/issues/2301");
it.skip(test_strict_lbl, test_strictness);
// Strictness handling changed in 2.3.x, possibly a bug: see http://github.com/mapnik/mapnik/issues/2301
it.skip('[skipped due to http://github.com/mapnik/mapnik/issues/2301]' + test_strict_lbl, test_strictness);
}
else {
it(test_strict_lbl, test_strictness);

View File

@ -44,16 +44,10 @@ suite('server', function() {
}, function(res) {
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('windshaft_cartodb'), "No 'windshaft_cartodb' version in " + parsed);
console.log("Windshaft-cartodb: " + parsed.windshaft_cartodb);
assert.ok(parsed.hasOwnProperty('windshaft'), "No 'windshaft' version in " + parsed);
console.log("Windshaft: " + parsed.windshaft);
assert.ok(parsed.hasOwnProperty('grainstore'), "No 'grainstore' version in " + parsed);
console.log("Grainstore: " + parsed.grainstore);
assert.ok(parsed.hasOwnProperty('node_mapnik'), "No 'node_mapnik' version in " + parsed);
console.log("Node-mapnik: " + parsed.node_mapnik);
assert.ok(parsed.hasOwnProperty('mapnik'), "No 'mapnik' version in " + parsed);
console.log("Mapnik: " + parsed.mapnik);
// TODO: check actual versions ?
done();
});
});

View File

@ -12,6 +12,7 @@ var lzmaWorker = new LZMA();
var redis = require('redis');
var nock = require('nock');
var log4js = require('log4js');
// set environment specific variables
global.environment = require(__dirname + '/../../config/environments/test');
@ -19,6 +20,11 @@ global.environment.name = 'test';
process.env.NODE_ENV = 'test';
// don't output logs in test environment to reduce noise
log4js.configure({ appenders: [] });
global.logger = log4js.getLogger();
// Utility function to compress & encode LZMA
function lzma_compress_to_base64(payload, mode, callback) {
lzmaWorker.compress(payload, mode,

View File

@ -61,7 +61,6 @@ suite('req2params', function() {
var req = {headers: { host:'localhost' }, query: {} };
baseController.req2params(prepareRequest(req), function(err, req) {
if ( err ) { done(err); return; }
//console.dir(req);
assert.ok(_.isObject(req.query), 'request has query');
assert.ok(!req.query.hasOwnProperty('dbuser'), 'dbuser was removed from query');
assert.ok(req.hasOwnProperty('params'), 'request has params');
@ -76,7 +75,6 @@ suite('req2params', function() {
var req = {headers: { host:'localhost' }, query: {map_key: '1234'} };
baseController.req2params(prepareRequest(req), function(err, req) {
if ( err ) { done(err); return; }
//console.dir(req);
assert.ok(_.isObject(req.query), 'request has query');
assert.ok(!req.query.hasOwnProperty('dbuser'), 'dbuser was removed from query');
assert.ok(req.hasOwnProperty('params'), 'request has params');