From d1226992c340baa092a0be6da9ed045c910e373b Mon Sep 17 00:00:00 2001 From: Simon Tokumine Date: Tue, 1 May 2012 19:00:14 +0100 Subject: [PATCH] clean up environment settings --- app.js | 6 ++-- cluster.js | 6 ++-- config/environments/development.js | 55 ++++++++++++++++++------------ config/environments/production.js | 35 ++++++++++++++----- config/environments/test.js | 42 ++++++++++++++++------- lib/cartodb/server_options.js | 5 ++- 6 files changed, 95 insertions(+), 54 deletions(-) diff --git a/app.js b/app.js index d707d5f3..5c996f0d 100755 --- a/app.js +++ b/app.js @@ -20,8 +20,6 @@ var _ = require('underscore') , Step = require('step') , cartoData = require('./lib/cartodb/carto_data') , CartodbWindshaft = require('./lib/cartodb/cartodb_windshaft'); - - // set environment specific variables global.settings = require(__dirname + '/config/settings'); @@ -32,5 +30,5 @@ var Windshaft = require('windshaft'); var serverOptions = require('./lib/cartodb/server_options'); ws = CartodbWindshaft(serverOptions); -ws.listen(global.environment.windshaft_port); -console.log("Windshaft tileserver started on port " + global.environment.windshaft_port); +ws.listen(global.environment.port); +console.log("Windshaft tileserver started on port " + global.environment.port); diff --git a/cluster.js b/cluster.js index 94f2e55d..c704f84c 100755 --- a/cluster.js +++ b/cluster.js @@ -23,7 +23,6 @@ var _ = require('underscore') , CartodbWindshaft = require('./lib/cartodb/cartodb_windshaft'); - // set environment specific variables global.settings = require(__dirname + '/config/settings'); global.environment = require(__dirname + '/config/environments/' + ENV); @@ -38,7 +37,6 @@ cluster(ws) .use(cluster.stats()) .use(cluster.pidfiles('pids')) .set('workers', 1) - .listen(global.environment.windshaft_port, global.environment.windshaft_host); + .listen(global.environment.windshaft_port, global.environment.host); -//ws.listen(global.environment.windshaft_port); -console.log("Windshaft tileserver started on port " + global.environment.windshaft_port); +console.log("Windshaft tileserver started on port " + global.environment.port); \ No newline at end of file diff --git a/config/environments/development.js b/config/environments/development.js index 1522e4fa..a2a152e4 100644 --- a/config/environments/development.js +++ b/config/environments/development.js @@ -1,22 +1,33 @@ -module.exports.name = 'development'; -module.exports.postgres = { - type: "postgis", - user: "tileuser", - host: '127.0.0.1', - port: 5432, - geometry_field: "the_geom", - extent: "-180,-90,180,90", - srid: 4326, - max_size: 0, - simplify: true - }; -module.exports.redis = {host: '127.0.0.1', - port: 6379, - idleTimeoutMillis: 1, - reapIntervalMillis: 1}; -module.exports.windshaft_port = 8181; -module.exports.windshaft_host = '127.0.0.1'; -module.exports.enable_cors = true; -module.exports.varnish_host = 'localhost'; -module.exports.varnish_port = 6082; -module.exports.cache_enabled = false; +var config = { + environment: 'development' + ,port: 8181 + ,host: '127.0.0.1' + ,enable_cors: true + ,postgres: { + type: "postgis", + user: "tileuser", + host: '127.0.0.1', + port: 5432, + geometry_field: "the_geom", + extent: "-180,-90,180,90", + srid: 4326, + max_size: 0, + simplify: true + } + ,redis: { + host: '127.0.0.1', + port: 6379, + idleTimeoutMillis: 1, + reapIntervalMillis: 1 + } + ,sqlapi: { + host: '127.0.0.1', + port: 8080 + } + ,varnish: { + host: 'localhost', + port: 6082 + } +}; + +module.exports = config; \ No newline at end of file diff --git a/config/environments/production.js b/config/environments/production.js index 6987aef5..de2e3b1c 100644 --- a/config/environments/production.js +++ b/config/environments/production.js @@ -1,9 +1,26 @@ -module.exports.name = 'production'; -module.exports.postgres = {user: 'tileuser', host: '127.0.0.1', port: 6432, simplify: true}; -module.exports.redis = {host: '127.0.0.1', port: 6379}; -module.exports.windshaft_port = 8181; -module.exports.windshaft_host = '127.0.0.1'; -module.exports.ttl_timeout = 600; // 10 minutes -module.exports.varnish_host = 'localhost'; -module.exports.varnish_port = 6082 -module.exports.cache_enabled = true; +var config = { + environment: 'production' + ,port: 8181 + ,host: '127.0.0.1' + ,enable_cors: true + ,postgres: { + user: "tileuser", + host: '127.0.0.1', + port: 6432, + simplify: true + } + ,redis: { + host: '127.0.0.1', + port: 6379 + } + ,sqlapi: { + host: '127.0.0.1', + port: 8080 + } + ,varnish: { + host: 'localhost', + port: 6082 + } +}; + +module.exports = config; \ No newline at end of file diff --git a/config/environments/test.js b/config/environments/test.js index 59078172..3618aafa 100644 --- a/config/environments/test.js +++ b/config/environments/test.js @@ -1,12 +1,30 @@ -module.exports.name = 'test'; -module.exports.postgres = {user: 'tileuser', host: '127.0.0.1', port: 5432, simplify: true}; -module.exports.redis = {host: '127.0.0.1', - port: 6379, - idleTimeoutMillis: 1, - reapIntervalMillis: 1}; -module.exports.windshaft_port = 8080; -module.exports.windshaft_host = '127.0.0.1'; -module.exports.enable_cors = true; -module.exports.varnish_host = ''; -module.exports.varnish_port = null; -module.exports.cache_enabled = false; +var config = { + environment: 'test' + ,port: 8080 + ,host: '127.0.0.1' + ,enable_cors: true + ,postgres: { + user: "tileuser", + host: '127.0.0.1', + port: 5432, + srid: 4326, + max_size: 0, + simplify: true + } + ,redis: { + host: '127.0.0.1', + port: 6379, + idleTimeoutMillis: 1, + reapIntervalMillis: 1 + } + ,sqlapi: { + host: '127.0.0.1', + port: 8080 + } + ,varnish: { + host: '', + port: null + } +}; + +module.exports = config; \ No newline at end of file diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index cbca11d9..7ade5e8b 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -8,9 +8,8 @@ module.exports = function(){ grainstore: {datasource: global.environment.postgres}, redis: global.environment.redis, enable_cors: global.environment.enable_cors, - varnish_host: global.environment.varnish_host, - varnish_port: global.environment.varnish_port, - cache_enabled: global.environment.cache_enabled, + varnish_host: global.environment.varnish.host, + varnish_port: global.environment.varnish.port, log_format: '[:date] :req[X-Real-IP] \033[90m:method\033[0m \033[36m:req[Host]:url\033[0m \033[90m:status :response-time ms -> :res[Content-Type]\033[0m' };