2018-10-23 23:45:42 +08:00
|
|
|
'use strict';
|
|
|
|
|
2018-06-08 19:46:42 +08:00
|
|
|
const fqdn = require('@carto/fqdn-sync');
|
2015-02-06 00:05:50 +08:00
|
|
|
var _ = require('underscore');
|
2019-10-07 16:06:01 +08:00
|
|
|
var OverviewsQueryRewriter = require('./utils/overviews-query-rewriter');
|
2016-02-03 02:23:07 +08:00
|
|
|
|
2015-07-05 02:41:22 +08:00
|
|
|
var rendererConfig = _.defaults(global.environment.renderer || {}, {
|
|
|
|
cache_ttl: 60000, // milliseconds
|
|
|
|
statsInterval: 60000,
|
|
|
|
mapnik: {
|
|
|
|
poolSize: 8,
|
2019-01-30 17:41:39 +08:00
|
|
|
poolMaxWaitingClients: 64,
|
2015-07-05 02:41:22 +08:00
|
|
|
metatile: 2,
|
|
|
|
bufferSize: 64,
|
|
|
|
snapToGrid: false,
|
|
|
|
clipByBox2d: false,
|
2018-01-16 17:23:46 +08:00
|
|
|
metrics: false,
|
2018-05-24 19:42:32 +08:00
|
|
|
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
|
|
|
|
},
|
2016-02-03 02:29:10 +08:00
|
|
|
limits: {}
|
2015-07-05 02:41:22 +08:00
|
|
|
},
|
2018-10-11 21:41:38 +08:00
|
|
|
http: {},
|
|
|
|
mvt: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
rendererConfig.mapnik.queryRewriter = new OverviewsQueryRewriter({
|
2019-11-12 20:10:35 +08:00
|
|
|
zoom_level: 'cartodb.CDB_ZoomFromScale(!scale_denominator!)'
|
2015-07-05 02:41:22 +08:00
|
|
|
});
|
|
|
|
|
2018-10-11 21:41:38 +08:00
|
|
|
rendererConfig.mvt.queryRewriter = new OverviewsQueryRewriter({
|
2019-11-12 20:10:35 +08:00
|
|
|
zoom_level: 'cartodb.CDB_ZoomFromScale(!scale_denominator!)'
|
2018-10-11 21:41:38 +08:00
|
|
|
});
|
2016-02-03 02:23:07 +08:00
|
|
|
|
2015-07-05 05:09:00 +08:00
|
|
|
// Perform keyword substitution in statsd
|
|
|
|
// See https://github.com/CartoDB/Windshaft-cartodb/issues/153
|
2016-04-14 19:40:02 +08:00
|
|
|
if (global.environment.statsd) {
|
|
|
|
if (global.environment.statsd.prefix) {
|
2018-06-08 19:46:42 +08:00
|
|
|
global.environment.statsd.prefix = global.environment.statsd.prefix.replace(/:host/, fqdn.reverse());
|
2015-07-05 05:09:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-14 23:09:07 +08:00
|
|
|
var analysisConfig = _.defaults(global.environment.analysis || {}, {
|
|
|
|
batch: {
|
2016-04-18 21:13:00 +08:00
|
|
|
inlineExecution: false,
|
2016-04-20 22:36:29 +08:00
|
|
|
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
|
|
|
|
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
|
2016-09-23 23:11:04 +08:00
|
|
|
},
|
|
|
|
logger: {
|
|
|
|
filename: undefined
|
2016-10-20 20:02:13 +08:00
|
|
|
},
|
|
|
|
limits: {}
|
2016-04-14 23:09:07 +08:00
|
|
|
});
|
|
|
|
|
2015-07-05 02:41:22 +08:00
|
|
|
module.exports = {
|
2015-07-05 05:09:00 +08:00
|
|
|
bind: {
|
|
|
|
port: global.environment.port,
|
|
|
|
host: global.environment.host
|
|
|
|
},
|
2018-05-09 20:59:21 +08:00
|
|
|
// Base URLs for the APIs
|
|
|
|
//
|
|
|
|
// See http://github.com/CartoDB/Windshaft-cartodb/wiki/Unified-Map-API
|
2019-10-08 17:02:32 +08:00
|
|
|
routes: global.environment.routes || {
|
|
|
|
api: [{
|
|
|
|
paths: [
|
|
|
|
'/api/v1',
|
2019-10-22 01:07:24 +08:00
|
|
|
'/user/:user/api/v1'
|
2019-10-08 17:02:32 +08:00
|
|
|
],
|
|
|
|
// Base url for the Detached Maps API
|
|
|
|
// "/api/v1/map" is the new API,
|
|
|
|
map: [{
|
|
|
|
paths: [
|
2019-10-22 01:07:24 +08:00
|
|
|
'/map'
|
2019-10-08 17:02:32 +08:00
|
|
|
]
|
|
|
|
}],
|
|
|
|
// Base url for the Templated Maps API
|
|
|
|
// "/api/v1/map/named" is the new API,
|
|
|
|
template: [{
|
|
|
|
paths: [
|
|
|
|
'/map/named'
|
|
|
|
]
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
},
|
2016-04-14 19:40:02 +08:00
|
|
|
grainstore: {
|
|
|
|
map: {
|
2014-02-04 23:26:03 +08:00
|
|
|
// TODO: allow to specify in configuration
|
|
|
|
srid: 3857
|
2012-09-20 00:52:13 +08:00
|
|
|
},
|
2018-05-25 20:44:58 +08:00
|
|
|
datasource: rendererConfig.mapnik.postgis || global.environment.postgres || {},
|
2016-04-14 19:40:02 +08:00
|
|
|
cachedir: global.environment.millstone.cache_basedir,
|
2016-12-02 00:02:40 +08:00
|
|
|
use_workers: rendererConfig.mapnik.useCartocssWorkers || false,
|
2016-04-14 19:40:02 +08:00
|
|
|
mapnik_version: global.environment.mapnik_version,
|
|
|
|
mapnik_tile_format: global.environment.mapnik_tile_format || 'png',
|
|
|
|
default_layergroup_ttl: global.environment.mapConfigTTL || 7200
|
|
|
|
},
|
|
|
|
statsd: global.environment.statsd,
|
|
|
|
renderCache: {
|
2020-04-05 00:51:22 +08:00
|
|
|
ttl: rendererConfig.cache_ttl || 60000,
|
|
|
|
statsInterval: rendererConfig.statsInterval || 60000
|
2016-04-14 19:40:02 +08:00
|
|
|
},
|
|
|
|
renderer: {
|
2018-05-25 00:36:45 +08:00
|
|
|
mvt: Object.assign({ dbPoolParams: global.environment.postgres.pool }, rendererConfig.mvt),
|
2018-05-24 19:53:29 +08:00
|
|
|
mapnik: rendererConfig.mapnik,
|
2018-05-25 00:36:45 +08:00
|
|
|
torque: Object.assign({ dbPoolParams: global.environment.postgres.pool }, rendererConfig.torque),
|
2016-04-14 19:40:02 +08:00
|
|
|
http: rendererConfig.http
|
|
|
|
},
|
2016-04-14 23:09:07 +08:00
|
|
|
|
|
|
|
analysis: {
|
|
|
|
batch: {
|
2016-04-18 21:13:00 +08:00
|
|
|
inlineExecution: analysisConfig.batch.inlineExecution,
|
2016-04-20 22:36:29 +08:00
|
|
|
endpoint: analysisConfig.batch.endpoint,
|
|
|
|
hostHeaderTemplate: analysisConfig.batch.hostHeaderTemplate
|
2016-09-23 23:11:04 +08:00
|
|
|
},
|
|
|
|
logger: {
|
|
|
|
filename: analysisConfig.logger.filename
|
2016-10-20 20:02:13 +08:00
|
|
|
},
|
|
|
|
limits: analysisConfig.limits
|
2016-04-14 23:09:07 +08:00
|
|
|
},
|
2016-04-14 19:40:02 +08:00
|
|
|
// Do not send unwatch on release. See http://github.com/CartoDB/Windshaft-cartodb/issues/161
|
2019-10-22 01:07:24 +08:00
|
|
|
redis: _.extend(global.environment.redis, { unwatchOnRelease: false }),
|
2016-04-14 19:40:02 +08:00
|
|
|
enable_cors: global.environment.enable_cors,
|
|
|
|
varnish_host: global.environment.varnish.host,
|
|
|
|
varnish_port: global.environment.varnish.port,
|
|
|
|
varnish_http_port: global.environment.varnish.http_port,
|
|
|
|
varnish_secret: global.environment.varnish.secret,
|
|
|
|
varnish_purge_enabled: global.environment.varnish.purge_enabled,
|
|
|
|
fastly: global.environment.fastly || {},
|
|
|
|
cache_enabled: global.environment.cache_enabled,
|
|
|
|
log_format: global.environment.log_format,
|
2020-04-27 18:46:27 +08:00
|
|
|
useProfiler: global.environment.useProfiler,
|
|
|
|
pubSubMetrics: Object.assign({ enabled: false }, global.environment.pubSubMetrics)
|
2014-02-19 13:45:29 +08:00
|
|
|
};
|