diff --git a/config/environments/development.js.example b/config/environments/development.js.example index d458976b..480f15b8 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -202,7 +202,9 @@ var config = { // - running an standalone server without any dependency on external services inlineExecution: false, // where the SQL API is running, it will use a custom Host header to specify the username. - endpoint: 'http://127.0.0.1:8080/api/v2/sql/job' + endpoint: 'http://127.0.0.1:8080/api/v2/sql/job', + // the template to use for adding the host header in the batch api requests + hostHeaderTemplate: '{{=it.username}}.localhost.lan' } } ,millstone: { diff --git a/config/environments/production.js.example b/config/environments/production.js.example index bfed10ff..2a457768 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -196,7 +196,9 @@ var config = { // - running an standalone server without any dependency on external services inlineExecution: false, // where the SQL API is running, it will use a custom Host header to specify the username. - endpoint: 'http://127.0.0.1:8080/api/v2/sql/job' + endpoint: 'http://127.0.0.1:8080/api/v2/sql/job', + // the template to use for adding the host header in the batch api requests + hostHeaderTemplate: '{{=it.username}}.localhost.lan' } } ,millstone: { diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 6886d028..72195fef 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -196,7 +196,9 @@ var config = { // - running an standalone server without any dependency on external services inlineExecution: false, // where the SQL API is running, it will use a custom Host header to specify the username. - endpoint: 'http://127.0.0.1:8080/api/v2/sql/job' + endpoint: 'http://127.0.0.1:8080/api/v2/sql/job', + // the template to use for adding the host header in the batch api requests + hostHeaderTemplate: '{{=it.username}}.localhost.lan' } } ,millstone: { diff --git a/config/environments/test.js.example b/config/environments/test.js.example index 758bfcb4..00c19628 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -197,7 +197,9 @@ var config = { // - running an standalone server without any dependency on external services inlineExecution: true, // where the SQL API is running, it will use a custom Host header to specify the username. - endpoint: 'http://127.0.0.1:8080/api/v2/sql/job' + endpoint: 'http://127.0.0.1:8080/api/v2/sql/job', + // the template to use for adding the host header in the batch api requests + hostHeaderTemplate: '{{=it.username}}.localhost.lan' } } ,millstone: { diff --git a/lib/cartodb/backends/analysis.js b/lib/cartodb/backends/analysis.js index dc06a8ac..5855da46 100644 --- a/lib/cartodb/backends/analysis.js +++ b/lib/cartodb/backends/analysis.js @@ -4,6 +4,7 @@ function AnalysisBackend(options) { var batchConfig = options.batch || {}; batchConfig.endpoint = batchConfig.endpoint || 'http://127.0.0.1:8080/api/v1/sql/job'; batchConfig.inlineExecution = batchConfig.inlineExecution || false; + batchConfig.hostHeaderTemplate = batchConfig.hostHeaderTemplate || '{{=it.username}}.localhost.lan'; this.batchConfig = batchConfig; } @@ -12,6 +13,7 @@ module.exports = AnalysisBackend; AnalysisBackend.prototype.create = function(analysisConfiguration, analysisDefinition, callback) { analysisConfiguration.batch.endpoint = this.batchConfig.endpoint; analysisConfiguration.batch.inlineExecution = this.batchConfig.inlineExecution; + analysisConfiguration.batch.hostHeaderTemplate = this.batchConfig.hostHeaderTemplate; camshaft.create(analysisConfiguration, analysisDefinition, callback); }; diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index a75bba58..22039b8c 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -34,7 +34,8 @@ if (global.environment.statsd) { var analysisConfig = _.defaults(global.environment.analysis || {}, { batch: { inlineExecution: false, - endpoint: 'http://127.0.0.1:8080/api/v2/sql/job' + endpoint: 'http://127.0.0.1:8080/api/v2/sql/job', + hostHeaderTemplate: '{{=it.username}}.localhost.lan' } }); @@ -92,7 +93,8 @@ module.exports = { analysis: { batch: { inlineExecution: analysisConfig.batch.inlineExecution, - endpoint: analysisConfig.batch.endpoint + endpoint: analysisConfig.batch.endpoint, + hostHeaderTemplate: analysisConfig.batch.hostHeaderTemplate } }, // Do not send unwatch on release. See http://github.com/CartoDB/Windshaft-cartodb/issues/161