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 01/14] 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, From ee38c717a5b0618dade286f377cd6a12f2d430d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 24 May 2018 13:53:29 +0200 Subject: [PATCH 02/14] Remove geojson renderer config --- config/environments/development.js.example | 19 ------------------- config/environments/production.js.example | 20 -------------------- config/environments/staging.js.example | 20 -------------------- config/environments/test.js.example | 20 -------------------- lib/cartodb/server_options.js | 11 +---------- 5 files changed, 1 insertion(+), 89 deletions(-) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 574eafed..9eff6616 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -235,25 +235,6 @@ var config = { cacheOnTimeout: true }, - geojson: { - dbPoolParams: { - // maximum number of resources to create at any given time - size: 16, - // max milliseconds a resource can go unused before it should be destroyed - idleTimeout: 3000, - // frequency to check for idle resources - reapInterval: 1000 - }, - - // SQL queries will be wrapped with ST_ClipByBox2D - // Returning the portion of a geometry falling within a rectangle - // It will only work if snapToGrid is enabled - clipByBox2d: false, // this requires postgis >=2.2 and geos >=3.5 - // geometries will be simplified using ST_RemoveRepeatedPoints - // which cost is no more expensive than snapping and results are - // much closer to the original geometry - removeRepeatedPoints: false // this requires postgis >=2.2 - }, // If enabled Mapnik will reuse the features retrieved from the database // instead of requesting them once per style inside a layer 'cache-features': true, diff --git a/config/environments/production.js.example b/config/environments/production.js.example index fee05568..9c2647c7 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -235,26 +235,6 @@ var config = { cacheOnTimeout: true }, - geojson: { - dbPoolParams: { - // maximum number of resources to create at any given time - size: 16, - // max milliseconds a resource can go unused before it should be destroyed - idleTimeout: 3000, - // frequency to check for idle resources - reapInterval: 1000 - }, - - // SQL queries will be wrapped with ST_ClipByBox2D - // Returning the portion of a geometry falling within a rectangle - // It will only work if snapToGrid is enabled - clipByBox2d: false, // this requires postgis >=2.2 and geos >=3.5 - // geometries will be simplified using ST_RemoveRepeatedPoints - // which cost is no more expensive than snapping and results are - // much closer to the original geometry - removeRepeatedPoints: false // this requires postgis >=2.2 - }, - // If enabled Mapnik will reuse the features retrieved from the database // instead of requesting them once per style inside a layer 'cache-features': true, diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 8e806946..6e396893 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -235,26 +235,6 @@ var config = { cacheOnTimeout: true }, - geojson: { - dbPoolParams: { - // maximum number of resources to create at any given time - size: 16, - // max milliseconds a resource can go unused before it should be destroyed - idleTimeout: 3000, - // frequency to check for idle resources - reapInterval: 1000 - }, - - // SQL queries will be wrapped with ST_ClipByBox2D - // Returning the portion of a geometry falling within a rectangle - // It will only work if snapToGrid is enabled - clipByBox2d: false, // this requires postgis >=2.2 and geos >=3.5 - // geometries will be simplified using ST_RemoveRepeatedPoints - // which cost is no more expensive than snapping and results are - // much closer to the original geometry - removeRepeatedPoints: false // this requires postgis >=2.2 - }, - // If enabled Mapnik will reuse the features retrieved from the database // instead of requesting them once per style inside a layer 'cache-features': true, diff --git a/config/environments/test.js.example b/config/environments/test.js.example index 1f4e34a6..56d1f9ef 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -227,26 +227,6 @@ var config = { cacheOnTimeout: true }, - geojson: { - dbPoolParams: { - // maximum number of resources to create at any given time - size: 16, - // max milliseconds a resource can go unused before it should be destroyed - idleTimeout: 3000, - // frequency to check for idle resources - reapInterval: 1000 - }, - - // SQL queries will be wrapped with ST_ClipByBox2D - // Returning the portion of a geometry falling within a rectangle - // It will only work if snapToGrid is enabled - clipByBox2d: false, // this requires postgis >=2.2 and geos >=3.5 - // geometries will be simplified using ST_RemoveRepeatedPoints - // which cost is no more expensive than snapping and results are - // much closer to the original geometry - removeRepeatedPoints: false // this requires postgis >=2.2 - }, - // If enabled Mapnik will reuse the features retrieved from the database // instead of requesting them once per style inside a layer 'cache-features': true, diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 739f6bca..2a2850b7 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -141,16 +141,7 @@ module.exports = { }, renderer: { mvt: rendererConfig.mvt, - mapnik: _.defaults(rendererConfig.mapnik, { - geojson: { - dbPoolParams: { - size: 16, - idleTimeout: 3000, - reapInterval: 1000 - }, - clipByBox2d: false - } - }), + mapnik: rendererConfig.mapnik, torque: rendererConfig.torque, http: rendererConfig.http }, From f4042851403a8333c7a221eafefbf9305876d1b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 24 May 2018 18:36:45 +0200 Subject: [PATCH 03/14] Use postgres pool configuration to have the same configuration for all renderers. --- config/environments/development.js.example | 21 ++------------------- config/environments/production.js.example | 11 +---------- config/environments/staging.js.example | 21 ++------------------- config/environments/test.js.example | 11 +---------- lib/cartodb/server_options.js | 4 ++-- 5 files changed, 8 insertions(+), 60 deletions(-) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 9eff6616..d5b3327a 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -137,15 +137,7 @@ var config = { //If enabled, MVTs will be generated with PostGIS directly, instead of using Mapnik, //PostGIS 2.4 is required for this to work //If disabled it will use Mapnik MVT generation - usePostGIS: false, - dbPoolParams: { - // maximum number of resources to create at any given time - size: 16, - // max milliseconds a resource can go unused before it should be destroyed - idleTimeout: 3000, - // frequency to check for idle resources - reapInterval: 1000 - } + usePostGIS: false }, mapnik: { // The size of the pool of internal mapnik backend @@ -261,16 +253,7 @@ var config = { src: __dirname + '/../../assets/default-placeholder.png' } }, - torque: { - dbPoolParams: { - // maximum number of resources to create at any given time - size: 16, - // max milliseconds a resource can go unused before it should be destroyed - idleTimeout: 3000, - // frequency to check for idle resources - reapInterval: 1000 - } - } + torque: {} } // anything analyses related ,analysis: { diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 9c2647c7..97d97302 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -261,16 +261,7 @@ var config = { src: __dirname + '/../../assets/default-placeholder.png' } }, - torque: { - dbPoolParams: { - // maximum number of resources to create at any given time - size: 16, - // max milliseconds a resource can go unused before it should be destroyed - idleTimeout: 3000, - // frequency to check for idle resources - reapInterval: 1000 - } - } + torque: {} } // anything analyses related ,analysis: { diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 6e396893..0dcd87b6 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -137,15 +137,7 @@ var config = { //If enabled, MVTs will be generated with PostGIS directly, instead of using Mapnik, //PostGIS 2.4 is required for this to work //If disabled it will use Mapnik MVT generation - usePostGIS: false, - dbPoolParams: { - // maximum number of resources to create at any given time - size: 16, - // max milliseconds a resource can go unused before it should be destroyed - idleTimeout: 3000, - // frequency to check for idle resources - reapInterval: 1000 - } + usePostGIS: false }, mapnik: { // The size of the pool of internal mapnik backend @@ -261,16 +253,7 @@ var config = { src: __dirname + '/../../assets/default-placeholder.png' } }, - torque: { - dbPoolParams: { - // maximum number of resources to create at any given time - size: 16, - // max milliseconds a resource can go unused before it should be destroyed - idleTimeout: 3000, - // frequency to check for idle resources - reapInterval: 1000 - } - } + torque: {} } // anything analyses related ,analysis: { diff --git a/config/environments/test.js.example b/config/environments/test.js.example index 56d1f9ef..082d4aa4 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -250,16 +250,7 @@ var config = { src: __dirname + '/../../assets/default-placeholder.png' } }, - torque: { - dbPoolParams: { - // maximum number of resources to create at any given time - size: 16, - // max milliseconds a resource can go unused before it should be destroyed - idleTimeout: 3000, - // frequency to check for idle resources - reapInterval: 1000 - } - } + torque: {} } // anything analyses related ,analysis: { diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 2a2850b7..9410b2f4 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -140,9 +140,9 @@ module.exports = { statsInterval: rendererConfig.statsInterval }, renderer: { - mvt: rendererConfig.mvt, + mvt: Object.assign({ dbPoolParams: global.environment.postgres.pool }, rendererConfig.mvt), mapnik: rendererConfig.mapnik, - torque: rendererConfig.torque, + torque: Object.assign({ dbPoolParams: global.environment.postgres.pool }, rendererConfig.torque), http: rendererConfig.http }, From 92255797d917adc44b80e38671d4408cf9cf5431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 25 May 2018 13:37:34 +0200 Subject: [PATCH 04/14] Add torque options to renderer factory --- lib/cartodb/api/api-router.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cartodb/api/api-router.js b/lib/cartodb/api/api-router.js index b7534559..f69652a3 100644 --- a/lib/cartodb/api/api-router.js +++ b/lib/cartodb/api/api-router.js @@ -311,7 +311,8 @@ function createRendererFactory ({ redisPool, serverOptions, environmentOptions } mapnik: serverOptions.renderer.mapnik }, http: serverOptions.renderer.http, - mvt: serverOptions.renderer.mvt + mvt: serverOptions.renderer.mvt, + torque: serverOptions.renderer.torque }); From 8fe192267d6616d5658a169a45b1f69c99c88ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 25 May 2018 13:37:57 +0200 Subject: [PATCH 05/14] cosmetic --- lib/cartodb/api/api-router.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/cartodb/api/api-router.js b/lib/cartodb/api/api-router.js index f69652a3..b0f42f03 100644 --- a/lib/cartodb/api/api-router.js +++ b/lib/cartodb/api/api-router.js @@ -315,6 +315,5 @@ function createRendererFactory ({ redisPool, serverOptions, environmentOptions } torque: serverOptions.renderer.torque }); - return rendererFactory; } From 1d0fa9a5f62ddf7fa3af4cff7a318f805fd8c085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 25 May 2018 14:23:19 +0200 Subject: [PATCH 06/14] Use the right port --- config/environments/development.js.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index d5b3327a..024c0013 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -118,7 +118,7 @@ var config = { user: "publicuser", password: "public", host: '127.0.0.1', - port: 6432 + port: 5432 } ,mapnik_version: undefined ,mapnik_tile_format: 'png8:m=h' From d003790e4d9b5b746bae5407ce526a0de0ee1a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 25 May 2018 14:25:43 +0200 Subject: [PATCH 07/14] Use the right port again --- config/environments/development.js.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 024c0013..503ac0d4 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -197,7 +197,7 @@ var config = { user: "publicuser", password: "public", host: '127.0.0.1', - port: 6432, + port: 5432, 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, From 5938836ff55909bc8bafa00d91c693ae28f0c501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 25 May 2018 14:36:06 +0200 Subject: [PATCH 08/14] Use default postgres port --- config/environments/production.js.example | 4 ++-- config/environments/staging.js.example | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 97d97302..0dc6275f 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -118,7 +118,7 @@ var config = { user: "publicuser", password: "public", host: '127.0.0.1', - port: 6432 + port: 5432 } ,mapnik_version: undefined ,mapnik_tile_format: 'png8:m=h' @@ -205,7 +205,7 @@ var config = { user: "publicuser", password: "public", host: '127.0.0.1', - port: 6432, + port: 5432, 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, diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 0dcd87b6..67a49e78 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -118,7 +118,7 @@ var config = { user: "publicuser", password: "public", host: '127.0.0.1', - port: 6432 + port: 5432 } ,mapnik_version: undefined ,mapnik_tile_format: 'png8:m=h' @@ -197,7 +197,7 @@ var config = { user: "publicuser", password: "public", host: '127.0.0.1', - port: 6432, + port: 5432, 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, From bbab9c1a6bbfbff6e7b561950ba12a17e092db4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 25 May 2018 14:44:58 +0200 Subject: [PATCH 09/14] Avoid breaking changes --- lib/cartodb/server_options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 9410b2f4..dff1280e 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -127,7 +127,7 @@ module.exports = { // TODO: allow to specify in configuration srid: 3857 }, - datasource: rendererConfig.mapnik.postgis, + datasource: rendererConfig.mapnik.postgis || global.environment.postgres || {}, cachedir: global.environment.millstone.cache_basedir, use_workers: rendererConfig.mapnik.useCartocssWorkers || false, mapnik_version: global.environment.mapnik_version, From 4e4399b727f9a3da8d8742547bf838c84a679da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 25 May 2018 18:00:53 +0200 Subject: [PATCH 10/14] Missing postgis configuration --- config/environments/test.js.example | 39 ++++++++++++++++++----------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/config/environments/test.js.example b/config/environments/test.js.example index 082d4aa4..5619c8ac 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -119,21 +119,7 @@ var config = { user: "test_windshaft_publicuser", password: "public", host: '127.0.0.1', - port: 5432, - 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: 5432 } ,mapnik_version: '' ,mapnik_tile_format: 'png8:m=h' @@ -214,6 +200,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: 5432, + 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 From b311f0e09196ec1fa652f1cff45fc756c853890a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 25 May 2018 18:38:31 +0200 Subject: [PATCH 11/14] Add generic pool configuration to postgres global config --- config/environments/development.js.example | 10 +++++++++- config/environments/production.js.example | 10 +++++++++- config/environments/staging.js.example | 10 +++++++++- config/environments/test.js.example | 10 +++++++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 503ac0d4..2a849fd0 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -118,7 +118,15 @@ var config = { user: "publicuser", password: "public", host: '127.0.0.1', - port: 5432 + port: 5432, + pool: { + // maximum number of resources to create at any given time + size: 16, + // max milliseconds a resource can go unused before it should be destroyed + idleTimeout: 3000, + // frequency to check for idle resources + reapInterval: 1000 + } } ,mapnik_version: undefined ,mapnik_tile_format: 'png8:m=h' diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 0dc6275f..5b1d50b8 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -118,7 +118,15 @@ var config = { user: "publicuser", password: "public", host: '127.0.0.1', - port: 5432 + port: 5432, + pool: { + // maximum number of resources to create at any given time + size: 16, + // max milliseconds a resource can go unused before it should be destroyed + idleTimeout: 3000, + // frequency to check for idle resources + reapInterval: 1000 + } } ,mapnik_version: undefined ,mapnik_tile_format: 'png8:m=h' diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 67a49e78..805f4ae7 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -118,7 +118,15 @@ var config = { user: "publicuser", password: "public", host: '127.0.0.1', - port: 5432 + port: 5432, + pool: { + // maximum number of resources to create at any given time + size: 16, + // max milliseconds a resource can go unused before it should be destroyed + idleTimeout: 3000, + // frequency to check for idle resources + reapInterval: 1000 + } } ,mapnik_version: undefined ,mapnik_tile_format: 'png8:m=h' diff --git a/config/environments/test.js.example b/config/environments/test.js.example index 5619c8ac..f0484a6b 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -119,7 +119,15 @@ var config = { user: "test_windshaft_publicuser", password: "public", host: '127.0.0.1', - port: 5432 + port: 5432, + pool: { + // maximum number of resources to create at any given time + size: 16, + // max milliseconds a resource can go unused before it should be destroyed + idleTimeout: 3000, + // frequency to check for idle resources + reapInterval: 1000 + } } ,mapnik_version: '' ,mapnik_tile_format: 'png8:m=h' From 4a8bfcf6478a1c9fdc440181da4bb4edf09f3234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Mon, 28 May 2018 10:03:07 +0200 Subject: [PATCH 12/14] Revert this commit: try to see what's happening here --- test/acceptance/ported/server_gettile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/acceptance/ported/server_gettile.js b/test/acceptance/ported/server_gettile.js index 4dc089c9..ce8f0e96 100644 --- a/test/acceptance/ported/server_gettile.js +++ b/test/acceptance/ported/server_gettile.js @@ -39,13 +39,13 @@ describe('server_gettile', function() { // --{ //////////////////////////////////////////////////////////////////// - it("get'ing a tile with default style should return an expected tile", function(done){ + it.only("get'ing a tile with default style should return an expected tile", function(done){ testClient.getTile(testClient.defaultTableMapConfig('test_table'), 13, 4011, 3088, imageCompareFn('test_table_13_4011_3088.png', done) ); }); - it("response of get tile can be served by renderer cache", function(done) { + it.only("response of get tile can be served by renderer cache", function(done) { var tileUrl = '/13/4011/3088.png'; var lastXwc; var mapConfig = testClient.defaultTableMapConfig('test_table'); @@ -60,7 +60,7 @@ describe('server_gettile', function() { var xwc = res.headers['x-windshaft-cache']; assert.ok(xwc); assert.ok(xwc > 0); - assert.ok(xwc >= lastXwc); + assert.ok(xwc >= lastXwc, `xwc: ${xwc}, lastXwc: ${lastXwc}`); requestTile(tileUrl, { cache_buster: 'wadus' }, function (err, res) { var xwc = res.headers['x-windshaft-cache']; From 4861d35628c66452363810b5247168bf9642631b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Mon, 28 May 2018 10:31:48 +0200 Subject: [PATCH 13/14] Cast to integer before comparing cache headers --- test/acceptance/ported/server_gettile.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/acceptance/ported/server_gettile.js b/test/acceptance/ported/server_gettile.js index ce8f0e96..5a31cd69 100644 --- a/test/acceptance/ported/server_gettile.js +++ b/test/acceptance/ported/server_gettile.js @@ -51,19 +51,19 @@ describe('server_gettile', function() { var mapConfig = testClient.defaultTableMapConfig('test_table'); testClient.withLayergroup(mapConfig, function (err, requestTile, finish) { requestTile(tileUrl, function (err, res) { - var xwc = res.headers['x-windshaft-cache']; + var xwc = parseInt(res.headers['x-windshaft-cache'], 10); assert.ok(xwc); assert.ok(xwc > 0); lastXwc = xwc; requestTile(tileUrl, function (err, res) { - var xwc = res.headers['x-windshaft-cache']; + var xwc = parseInt(res.headers['x-windshaft-cache'], 10); assert.ok(xwc); assert.ok(xwc > 0); - assert.ok(xwc >= lastXwc, `xwc: ${xwc}, lastXwc: ${lastXwc}`); + assert.ok(xwc >= lastXwc); requestTile(tileUrl, { cache_buster: 'wadus' }, function (err, res) { - var xwc = res.headers['x-windshaft-cache']; + var xwc = parseInt(res.headers['x-windshaft-cache'], 10); assert.ok(!xwc); finish(done); @@ -103,7 +103,7 @@ describe('server_gettile', function() { testClient.withLayergroup(mapConfig, validateLayergroup, function(err, requestTile, finish) { requestTile(tileUrl, function(err, res) { - var xwc = res.headers['x-windshaft-cache']; + var xwc = parseInt(res.headers['x-windshaft-cache'], 10); assert.ok(!xwc); requestTile(tileUrl, function (err, res) { @@ -111,7 +111,7 @@ describe('server_gettile', function() { res.headers.hasOwnProperty('x-windshaft-cache'), "Did not hit renderer cache on second time" ); - assert.ok(res.headers['x-windshaft-cache'] >= 0); + assert.ok(parseInt(res.headers['x-windshaft-cache'], 10) >= 0); assert.imageBufferIsSimilarToFile(res.body, imageFixture, IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) { From 8b05d75f97dba64bb8dc9d4d3993b081bedf18fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Mon, 28 May 2018 10:32:31 +0200 Subject: [PATCH 14/14] Revert test runner filters --- test/acceptance/ported/server_gettile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/acceptance/ported/server_gettile.js b/test/acceptance/ported/server_gettile.js index 5a31cd69..b83a9720 100644 --- a/test/acceptance/ported/server_gettile.js +++ b/test/acceptance/ported/server_gettile.js @@ -39,13 +39,13 @@ describe('server_gettile', function() { // --{ //////////////////////////////////////////////////////////////////// - it.only("get'ing a tile with default style should return an expected tile", function(done){ + it("get'ing a tile with default style should return an expected tile", function(done){ testClient.getTile(testClient.defaultTableMapConfig('test_table'), 13, 4011, 3088, imageCompareFn('test_table_13_4011_3088.png', done) ); }); - it.only("response of get tile can be served by renderer cache", function(done) { + it("response of get tile can be served by renderer cache", function(done) { var tileUrl = '/13/4011/3088.png'; var lastXwc; var mapConfig = testClient.defaultTableMapConfig('test_table');