Merge branch 'standalone-server' into standalone-server-mvt
This commit is contained in:
commit
0d3e96ee9f
4
app.js
4
app.js
@ -87,9 +87,9 @@ var server = cartodbWindshaft(serverOptions);
|
|||||||
// 128 is a good number if you have up to 1024 filedescriptors
|
// 128 is a good number if you have up to 1024 filedescriptors
|
||||||
// 4 is good if you have max 32 filedescriptors
|
// 4 is good if you have max 32 filedescriptors
|
||||||
// 1 is good if you have max 16 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;
|
var version = require("./package").version;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
|
var debug = require('debug')('windshaft:templates');
|
||||||
var step = require('step');
|
var step = require('step');
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
var dot = require('dot');
|
var dot = require('dot');
|
||||||
@ -327,7 +328,7 @@ o.updTemplate = function(owner, tpl_id, template, callback) {
|
|||||||
function handleTemplateUpdate(err, didSetNewField) {
|
function handleTemplateUpdate(err, didSetNewField) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
if (didSetNewField) {
|
if (didSetNewField) {
|
||||||
console.warn('New template created on update operation');
|
debug('New template created on update operation');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -72,7 +72,6 @@ BaseController.prototype.req2params = function(req, callback){
|
|||||||
if ( req.params.token ) {
|
if ( req.params.token ) {
|
||||||
// Token might match the following patterns:
|
// Token might match the following patterns:
|
||||||
// - {user}@{tpl_id}@{token}:{cache_buster}
|
// - {user}@{tpl_id}@{token}:{cache_buster}
|
||||||
//console.log("Request parameters include token " + req.params.token);
|
|
||||||
var tksplit = req.params.token.split(':');
|
var tksplit = req.params.token.split(':');
|
||||||
req.params.token = tksplit[0];
|
req.params.token = tksplit[0];
|
||||||
if ( tksplit.length > 1 ) {
|
if ( tksplit.length > 1 ) {
|
||||||
@ -97,7 +96,6 @@ BaseController.prototype.req2params = function(req, callback){
|
|||||||
/*var template_hash = */tksplit.shift(); // unused
|
/*var template_hash = */tksplit.shift(); // unused
|
||||||
}
|
}
|
||||||
req.params.token = tksplit.shift();
|
req.params.token = tksplit.shift();
|
||||||
//console.log("Request for token " + req.params.token + " with signature from " + req.params.signer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,12 +116,6 @@ LayergroupController.prototype.tileOrLayer = function (req, res) {
|
|||||||
function mapController$finalize(err, tile, headers, stats) {
|
function mapController$finalize(err, tile, headers, stats) {
|
||||||
req.profiler.add(stats);
|
req.profiler.add(stats);
|
||||||
self.finalizeGetTileOrGrid(err, req, res, tile, headers);
|
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) {
|
function sendResponse(err, affectedTables) {
|
||||||
req.profiler.done('affectedTables');
|
req.profiler.done('affectedTables');
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('ERROR generating cache channel: ' + err);
|
global.logger.warn('ERROR generating cache channel: ' + err);
|
||||||
}
|
}
|
||||||
if (!!affectedTables) {
|
if (!!affectedTables) {
|
||||||
var tablesCacheEntry = new TablesCacheEntry(dbName, affectedTables);
|
var tablesCacheEntry = new TablesCacheEntry(dbName, affectedTables);
|
||||||
|
@ -264,7 +264,7 @@ MapController.prototype.afterLayergroupCreate = function(req, res, mapconfig, la
|
|||||||
req.profiler.done('incMapviewCount');
|
req.profiler.done('incMapviewCount');
|
||||||
}
|
}
|
||||||
if ( err ) {
|
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();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -48,7 +48,7 @@ NamedMapsController.prototype.sendResponse = function(req, res, resource, header
|
|||||||
function sendResponse(err, result) {
|
function sendResponse(err, result) {
|
||||||
req.profiler.done('affectedTables');
|
req.profiler.done('affectedTables');
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('ERROR generating cache channel: ' + err);
|
global.logger.log('ERROR generating cache channel: ' + err);
|
||||||
}
|
}
|
||||||
if (!result || !!result.affectedTables) {
|
if (!result || !!result.affectedTables) {
|
||||||
// we increase cache control as we can invalidate it
|
// we increase cache control as we can invalidate it
|
||||||
|
@ -14,12 +14,11 @@ CdbRequest.prototype.userByReq = function(req) {
|
|||||||
}
|
}
|
||||||
var mat = host.match(this.RE_USER_FROM_HOST);
|
var mat = host.match(this.RE_USER_FROM_HOST);
|
||||||
if ( ! mat ) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
// console.log("Matches: "); console.dir(mat);
|
|
||||||
if ( mat.length !== 2 ) {
|
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;
|
||||||
}
|
}
|
||||||
return mat[1];
|
return mat[1];
|
||||||
|
@ -78,9 +78,9 @@ module.exports = function(serverOptions) {
|
|||||||
error: !!err ? JSON.stringify(err.message) : undefined
|
error: !!err ? JSON.stringify(err.message) : undefined
|
||||||
});
|
});
|
||||||
if (err) {
|
if (err) {
|
||||||
console.warn(logMessage);
|
global.logger.warn(logMessage);
|
||||||
} else {
|
} else {
|
||||||
console.info(logMessage);
|
global.logger.info(logMessage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ module.exports = {
|
|||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
debug("last statsd client socket error repeated " + count + " times");
|
debug("last statsd client socket error repeated " + count + " times");
|
||||||
instance.last_error.count = 1;
|
instance.last_error.count = 1;
|
||||||
//console.log("Clearing interval");
|
|
||||||
clearInterval(instance.last_error.interval);
|
clearInterval(instance.last_error.interval);
|
||||||
instance.last_error.interval = null;
|
instance.last_error.interval = null;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,6 @@ function rendererCacheErrorListener() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function gcTimingListener(gcTime) {
|
function gcTimingListener(gcTime) {
|
||||||
console.log('gctime');
|
|
||||||
global.statsClient.timing('windshaft.rendercache.gc', gcTime);
|
global.statsClient.timing('windshaft.rendercache.gc', gcTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,6 @@ suite(suiteName, function() {
|
|||||||
var errors = [];
|
var errors = [];
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
errors.push(err.message);
|
errors.push(err.message);
|
||||||
console.log("Error: " + err);
|
|
||||||
}
|
}
|
||||||
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
|
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
@ -278,7 +277,6 @@ suite(suiteName, function() {
|
|||||||
var errors = [];
|
var errors = [];
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
errors.push(err.message);
|
errors.push(err.message);
|
||||||
console.log("Error: " + err);
|
|
||||||
}
|
}
|
||||||
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
|
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
@ -500,7 +498,6 @@ suite(suiteName, function() {
|
|||||||
var errors = [];
|
var errors = [];
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
errors.push(err.message);
|
errors.push(err.message);
|
||||||
console.log("Error: " + err);
|
|
||||||
}
|
}
|
||||||
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
|
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
@ -831,7 +828,6 @@ suite(suiteName, function() {
|
|||||||
var errors = [];
|
var errors = [];
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
errors.push(err.message);
|
errors.push(err.message);
|
||||||
console.log("Error: " + err);
|
|
||||||
}
|
}
|
||||||
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
|
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
@ -950,7 +946,6 @@ suite(suiteName, function() {
|
|||||||
var errors = [];
|
var errors = [];
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
errors.push(err.message);
|
errors.push(err.message);
|
||||||
console.log("Error: " + err);
|
|
||||||
}
|
}
|
||||||
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
|
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
@ -1114,7 +1109,6 @@ suite(suiteName, function() {
|
|||||||
var errors = [];
|
var errors = [];
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
errors.push(err.message);
|
errors.push(err.message);
|
||||||
console.log("Error: " + err);
|
|
||||||
}
|
}
|
||||||
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
|
redis_client.keys("map_cfg|" + expected_token, function(err, matches) {
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
@ -1219,7 +1213,6 @@ suite(suiteName, function() {
|
|||||||
function finish(err) {
|
function finish(err) {
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
errors.push(err.message);
|
errors.push(err.message);
|
||||||
console.log("Error: " + err);
|
|
||||||
}
|
}
|
||||||
if ( errors.length ) {
|
if ( errors.length ) {
|
||||||
done(new Error(errors));
|
done(new Error(errors));
|
||||||
|
@ -139,8 +139,6 @@ describe('named static maps', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(url);
|
|
||||||
|
|
||||||
var statusCode = options.status || 200;
|
var statusCode = options.status || 200;
|
||||||
|
|
||||||
var expectedResponse = {
|
var expectedResponse = {
|
||||||
|
@ -41,7 +41,6 @@ describe('multilayer', function() {
|
|||||||
fs.readFile(filename, "binary", function(err, file) {
|
fs.readFile(filename, "binary", function(err, file) {
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
response.writeHead(404, {'Content-Type': 'text/plain'});
|
response.writeHead(404, {'Content-Type': 'text/plain'});
|
||||||
console.log("File '" + filename + "' not found");
|
|
||||||
response.write("404 Not Found\n");
|
response.write("404 Not Found\n");
|
||||||
} else {
|
} else {
|
||||||
response.writeHead(200);
|
response.writeHead(200);
|
||||||
@ -499,7 +498,6 @@ describe('multilayer', function() {
|
|||||||
},
|
},
|
||||||
function do_get_tile(err)
|
function do_get_tile(err)
|
||||||
{
|
{
|
||||||
console.log(err);
|
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
var next = this;
|
var next = this;
|
||||||
assert.response(server, {
|
assert.response(server, {
|
||||||
@ -742,7 +740,6 @@ describe('multilayer', function() {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
function finish(err) {
|
function finish(err) {
|
||||||
//if ( err ) console.log(err.stack);
|
|
||||||
var errors = [];
|
var errors = [];
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
errors.push(''+err);
|
errors.push(''+err);
|
||||||
|
@ -201,10 +201,8 @@ describe('server_gettile', function() {
|
|||||||
};
|
};
|
||||||
var test_strict_lbl = "unused directives are not tolerated if strict";
|
var test_strict_lbl = "unused directives are not tolerated if strict";
|
||||||
if ( semver.satisfies(mapnik.versions.mapnik, '2.3.x') ) {
|
if ( semver.satisfies(mapnik.versions.mapnik, '2.3.x') ) {
|
||||||
// Strictness handling changed in 2.3.x, possibly a bug:
|
// Strictness handling changed in 2.3.x, possibly a bug: see http://github.com/mapnik/mapnik/issues/2301
|
||||||
// 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);
|
||||||
console.warn("Strictness test skipped due to http://github.com/mapnik/mapnik/issues/2301");
|
|
||||||
it.skip(test_strict_lbl, test_strictness);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
it(test_strict_lbl, test_strictness);
|
it(test_strict_lbl, test_strictness);
|
||||||
|
@ -44,16 +44,10 @@ suite('server', function() {
|
|||||||
}, function(res) {
|
}, function(res) {
|
||||||
var parsed = JSON.parse(res.body);
|
var parsed = JSON.parse(res.body);
|
||||||
assert.ok(parsed.hasOwnProperty('windshaft_cartodb'), "No 'windshaft_cartodb' version in " + parsed);
|
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);
|
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);
|
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);
|
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);
|
assert.ok(parsed.hasOwnProperty('mapnik'), "No 'mapnik' version in " + parsed);
|
||||||
console.log("Mapnik: " + parsed.mapnik);
|
|
||||||
// TODO: check actual versions ?
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -12,6 +12,7 @@ var lzmaWorker = new LZMA();
|
|||||||
|
|
||||||
var redis = require('redis');
|
var redis = require('redis');
|
||||||
var nock = require('nock');
|
var nock = require('nock');
|
||||||
|
var log4js = require('log4js');
|
||||||
|
|
||||||
// set environment specific variables
|
// set environment specific variables
|
||||||
global.environment = require(__dirname + '/../../config/environments/test');
|
global.environment = require(__dirname + '/../../config/environments/test');
|
||||||
@ -19,6 +20,11 @@ global.environment.name = 'test';
|
|||||||
process.env.NODE_ENV = '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
|
// Utility function to compress & encode LZMA
|
||||||
function lzma_compress_to_base64(payload, mode, callback) {
|
function lzma_compress_to_base64(payload, mode, callback) {
|
||||||
lzmaWorker.compress(payload, mode,
|
lzmaWorker.compress(payload, mode,
|
||||||
|
@ -61,7 +61,6 @@ suite('req2params', function() {
|
|||||||
var req = {headers: { host:'localhost' }, query: {} };
|
var req = {headers: { host:'localhost' }, query: {} };
|
||||||
baseController.req2params(prepareRequest(req), function(err, req) {
|
baseController.req2params(prepareRequest(req), function(err, req) {
|
||||||
if ( err ) { done(err); return; }
|
if ( err ) { done(err); return; }
|
||||||
//console.dir(req);
|
|
||||||
assert.ok(_.isObject(req.query), 'request has query');
|
assert.ok(_.isObject(req.query), 'request has query');
|
||||||
assert.ok(!req.query.hasOwnProperty('dbuser'), 'dbuser was removed from query');
|
assert.ok(!req.query.hasOwnProperty('dbuser'), 'dbuser was removed from query');
|
||||||
assert.ok(req.hasOwnProperty('params'), 'request has params');
|
assert.ok(req.hasOwnProperty('params'), 'request has params');
|
||||||
@ -76,7 +75,6 @@ suite('req2params', function() {
|
|||||||
var req = {headers: { host:'localhost' }, query: {map_key: '1234'} };
|
var req = {headers: { host:'localhost' }, query: {map_key: '1234'} };
|
||||||
baseController.req2params(prepareRequest(req), function(err, req) {
|
baseController.req2params(prepareRequest(req), function(err, req) {
|
||||||
if ( err ) { done(err); return; }
|
if ( err ) { done(err); return; }
|
||||||
//console.dir(req);
|
|
||||||
assert.ok(_.isObject(req.query), 'request has query');
|
assert.ok(_.isObject(req.query), 'request has query');
|
||||||
assert.ok(!req.query.hasOwnProperty('dbuser'), 'dbuser was removed from query');
|
assert.ok(!req.query.hasOwnProperty('dbuser'), 'dbuser was removed from query');
|
||||||
assert.ok(req.hasOwnProperty('params'), 'request has params');
|
assert.ok(req.hasOwnProperty('params'), 'request has params');
|
||||||
|
Loading…
Reference in New Issue
Block a user