From 1668392296c0512a86aad99250704cf7c70598b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 24 May 2018 13:42:32 +0200 Subject: [PATCH] Move 'postgres' attributes inside Mapnik's renderer configuration and keep params relative to user's connection --- config/environments/development.js.example | 47 +++++++++++----------- config/environments/production.js.example | 41 +++++++++++-------- config/environments/staging.js.example | 41 +++++++++++-------- lib/cartodb/server_options.js | 11 ++++- 4 files changed, 82 insertions(+), 58 deletions(-) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index f9c58abb..574eafed 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -115,32 +115,10 @@ var config = { // Supported labels: 'user_id', 'user_password' (both read from redis) ,postgres_auth_pass: '<%= user_password %>' ,postgres: { - // Parameters to pass to datasource plugin of mapnik - // See http://github.com/mapnik/mapnik/wiki/PostGIS - type: "postgis", user: "publicuser", password: "public", host: '127.0.0.1', - port: 5432, - extent: "-20037508.3,-20037508.3,20037508.3,20037508.3", - /* experimental - geometry_field: "the_geom", - extent: "-180,-90,180,90", - srid: 4326, - */ - // max number of rows to return when querying data, 0 means no limit - row_limit: 65535, - simplify_geometries: true, - use_overviews: true, // use overviews to retrieve raster - /* - * Set persist_connection to false if you want - * database connections to be closed on renderer - * expiration (1 minute after last use). - * Setting to true (the default) would never - * close any connection for the server's lifetime - */ - persist_connection: false, - max_size: 500 + port: 6432 } ,mapnik_version: undefined ,mapnik_tile_format: 'png8:m=h' @@ -221,6 +199,29 @@ var config = { // It will only work if snapToGrid is enabled clipByBox2d: false, // this requires postgis >=2.2 and geos >=3.5 + postgis: { + // Parameters to pass to datasource plugin of mapnik + // See http://github.com/mapnik/mapnik/wiki/PostGIS + user: "publicuser", + password: "public", + host: '127.0.0.1', + port: 6432, + extent: "-20037508.3,-20037508.3,20037508.3,20037508.3", + // max number of rows to return when querying data, 0 means no limit + row_limit: 65535, + /* + * Set persist_connection to false if you want + * database connections to be closed on renderer + * expiration (1 minute after last use). + * Setting to true (the default) would never + * close any connection for the server's lifetime + */ + persist_connection: false, + simplify_geometries: true, + use_overviews: true, // use overviews to retrieve raster + max_size: 500 + }, + limits: { // Time in milliseconds a render request can take before it fails, some notes: // - 0 means no render limit diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 89c5e5bd..fee05568 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -115,26 +115,10 @@ var config = { // Supported labels: 'user_id', 'user_password' (both read from redis) ,postgres_auth_pass: '<%= user_password %>' ,postgres: { - // Parameters to pass to datasource plugin of mapnik - // See http://github.com/mapnik/mapnik/wiki/PostGIS user: "publicuser", password: "public", host: '127.0.0.1', - port: 6432, - extent: "-20037508.3,-20037508.3,20037508.3,20037508.3", - // max number of rows to return when querying data, 0 means no limit - row_limit: 65535, - /* - * Set persist_connection to false if you want - * database connections to be closed on renderer - * expiration (1 minute after last use). - * Setting to true (the default) would never - * close any connection for the server's lifetime - */ - persist_connection: false, - simplify_geometries: true, - use_overviews: true, // use overviews to retrieve raster - max_size: 500 + port: 6432 } ,mapnik_version: undefined ,mapnik_tile_format: 'png8:m=h' @@ -215,6 +199,29 @@ var config = { // It will only work if snapToGrid is enabled clipByBox2d: false, // this requires postgis >=2.2 and geos >=3.5 + postgis: { + // Parameters to pass to datasource plugin of mapnik + // See http://github.com/mapnik/mapnik/wiki/PostGIS + user: "publicuser", + password: "public", + host: '127.0.0.1', + port: 6432, + extent: "-20037508.3,-20037508.3,20037508.3,20037508.3", + // max number of rows to return when querying data, 0 means no limit + row_limit: 65535, + /* + * Set persist_connection to false if you want + * database connections to be closed on renderer + * expiration (1 minute after last use). + * Setting to true (the default) would never + * close any connection for the server's lifetime + */ + persist_connection: false, + simplify_geometries: true, + use_overviews: true, // use overviews to retrieve raster + max_size: 500 + }, + limits: { // Time in milliseconds a render request can take before it fails, some notes: // - 0 means no render limit diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 76353f9b..8e806946 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -115,26 +115,10 @@ var config = { // Supported labels: 'user_id', 'user_password' (both read from redis) ,postgres_auth_pass: '<%= user_password %>' ,postgres: { - // Parameters to pass to datasource plugin of mapnik - // See http://github.com/mapnik/mapnik/wiki/PostGIS user: "publicuser", password: "public", host: '127.0.0.1', - port: 6432, - extent: "-20037508.3,-20037508.3,20037508.3,20037508.3", - // max number of rows to return when querying data, 0 means no limit - row_limit: 65535, - simplify_geometries: true, - use_overviews: true, // use overviews to retrieve raster - /* - * Set persist_connection to false if you want - * database connections to be closed on renderer - * expiration (1 minute after last use). - * Setting to true (the default) would never - * close any connection for the server's lifetime - */ - persist_connection: false, - max_size: 500 + port: 6432 } ,mapnik_version: undefined ,mapnik_tile_format: 'png8:m=h' @@ -215,6 +199,29 @@ var config = { // It will only work if snapToGrid is enabled clipByBox2d: false, // this requires postgis >=2.2 and geos >=3.5 + postgis: { + // Parameters to pass to datasource plugin of mapnik + // See http://github.com/mapnik/mapnik/wiki/PostGIS + user: "publicuser", + password: "public", + host: '127.0.0.1', + port: 6432, + extent: "-20037508.3,-20037508.3,20037508.3,20037508.3", + // max number of rows to return when querying data, 0 means no limit + row_limit: 65535, + /* + * Set persist_connection to false if you want + * database connections to be closed on renderer + * expiration (1 minute after last use). + * Setting to true (the default) would never + * close any connection for the server's lifetime + */ + persist_connection: false, + simplify_geometries: true, + use_overviews: true, // use overviews to retrieve raster + max_size: 500 + }, + limits: { // Time in milliseconds a render request can take before it fails, some notes: // - 0 means no render limit diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index c3d0fdb8..739f6bca 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -16,6 +16,15 @@ var rendererConfig = _.defaults(global.environment.renderer || {}, { snapToGrid: false, clipByBox2d: false, metrics: false, + postgis: { + simplify_geometries: false, + extent: '-20037508.3,-20037508.3,20037508.3,20037508.3', + row_limit: 65535, + persist_connection: false, + use_overviews: true, + max_size: 500, + twkb_encoding: true + }, limits: {} }, http: {} @@ -118,7 +127,7 @@ module.exports = { // TODO: allow to specify in configuration srid: 3857 }, - datasource: global.environment.postgres, + datasource: rendererConfig.mapnik.postgis, cachedir: global.environment.millstone.cache_basedir, use_workers: rendererConfig.mapnik.useCartocssWorkers || false, mapnik_version: global.environment.mapnik_version,