Merge pull request #327 from CartoDB/http-agent-configuration

Make http and https globalAgent options configurable
This commit is contained in:
Raul Ochoa 2015-08-27 16:44:55 +02:00
commit 473ae13a03
8 changed files with 48 additions and 3 deletions

View File

@ -1,9 +1,13 @@
# Changelog # Changelog
## 2.11.1 ## 2.12.0
Released 2015-mm-dd Released 2015-mm-dd
New features:
- Make http and https globalAgent options configurable
* If config is not provided it configures them with default values
## 2.11.0 ## 2.11.0

13
app.js
View File

@ -9,6 +9,8 @@
var path = require('path'); var path = require('path');
var fs = require('fs'); var fs = require('fs');
var http = require('http');
var https = require('https');
var RedisPool = require('redis-mpool'); var RedisPool = require('redis-mpool');
var _ = require('underscore'); var _ = require('underscore');
@ -72,6 +74,17 @@ var redisOpts = _.defaults(global.environment.redis, {
}); });
var redisPool = new RedisPool(redisOpts); var redisPool = new RedisPool(redisOpts);
// set global HTTP and HTTPS agent default configurations
// ref https://nodejs.org/api/http.html#http_new_agent_options
var agentOptions = _.defaults(global.environment.httpAgent || {}, {
keepAlive: false,
keepAliveMsecs: 1000,
maxSockets: Infinity,
maxFreeSockets: 256
});
http.globalAgent = new http.Agent(agentOptions);
https.globalAgent = new https.Agent(agentOptions);
// Include cartodb_windshaft only _after_ the "global" variable is set // Include cartodb_windshaft only _after_ the "global" variable is set
// See https://github.com/Vizzuality/Windshaft-cartodb/issues/28 // See https://github.com/Vizzuality/Windshaft-cartodb/issues/28
var cartodbWindshaft = require('./lib/cartodb/cartodb_windshaft'), var cartodbWindshaft = require('./lib/cartodb/cartodb_windshaft'),

View File

@ -196,6 +196,13 @@ var config = {
unwatchOnRelease: false, // Send unwatch on release, see http://github.com/CartoDB/Windshaft-cartodb/issues/161 unwatchOnRelease: false, // Send unwatch on release, see http://github.com/CartoDB/Windshaft-cartodb/issues/161
noReadyCheck: true // Check `no_ready_check` at https://github.com/mranney/node_redis/tree/v0.12.1#overloading noReadyCheck: true // Check `no_ready_check` at https://github.com/mranney/node_redis/tree/v0.12.1#overloading
} }
// For more details about this options check https://nodejs.org/api/http.html#http_new_agent_options
,httpAgent: {
keepAlive: true,
keepAliveMsecs: 1000,
maxSockets: 25,
maxFreeSockets: 256
}
,varnish: { ,varnish: {
host: 'localhost', host: 'localhost',
port: 6082, // the por for the telnet interface where varnish is listening to port: 6082, // the por for the telnet interface where varnish is listening to

View File

@ -190,6 +190,13 @@ var config = {
unwatchOnRelease: false, // Send unwatch on release, see http://github.com/CartoDB/Windshaft-cartodb/issues/161 unwatchOnRelease: false, // Send unwatch on release, see http://github.com/CartoDB/Windshaft-cartodb/issues/161
noReadyCheck: true // Check `no_ready_check` at https://github.com/mranney/node_redis/tree/v0.12.1#overloading noReadyCheck: true // Check `no_ready_check` at https://github.com/mranney/node_redis/tree/v0.12.1#overloading
} }
// For more details about this options check https://nodejs.org/api/http.html#http_new_agent_options
,httpAgent: {
keepAlive: true,
keepAliveMsecs: 1000,
maxSockets: 25,
maxFreeSockets: 256
}
,varnish: { ,varnish: {
host: 'localhost', host: 'localhost',
port: 6082, // the por for the telnet interface where varnish is listening to port: 6082, // the por for the telnet interface where varnish is listening to

View File

@ -190,6 +190,13 @@ var config = {
unwatchOnRelease: false, // Send unwatch on release, see http://github.com/CartoDB/Windshaft-cartodb/issues/161 unwatchOnRelease: false, // Send unwatch on release, see http://github.com/CartoDB/Windshaft-cartodb/issues/161
noReadyCheck: true // Check `no_ready_check` at https://github.com/mranney/node_redis/tree/v0.12.1#overloading noReadyCheck: true // Check `no_ready_check` at https://github.com/mranney/node_redis/tree/v0.12.1#overloading
} }
// For more details about this options check https://nodejs.org/api/http.html#http_new_agent_options
,httpAgent: {
keepAlive: true,
keepAliveMsecs: 1000,
maxSockets: 25,
maxFreeSockets: 256
}
,varnish: { ,varnish: {
host: 'localhost', host: 'localhost',
port: 6082, // the por for the telnet interface where varnish is listening to port: 6082, // the por for the telnet interface where varnish is listening to

View File

@ -192,6 +192,13 @@ var config = {
unwatchOnRelease: false, // Send unwatch on release, see http://github.com/CartoDB/Windshaft-cartodb/issues/161 unwatchOnRelease: false, // Send unwatch on release, see http://github.com/CartoDB/Windshaft-cartodb/issues/161
noReadyCheck: true // Check `no_ready_check` at https://github.com/mranney/node_redis/tree/v0.12.1#overloading noReadyCheck: true // Check `no_ready_check` at https://github.com/mranney/node_redis/tree/v0.12.1#overloading
} }
// For more details about this options check https://nodejs.org/api/http.html#http_new_agent_options
,httpAgent: {
keepAlive: true,
keepAliveMsecs: 1000,
maxSockets: 25,
maxFreeSockets: 256
}
,varnish: { ,varnish: {
host: '', host: '',
port: null, // the por for the telnet interface where varnish is listening to port: null, // the por for the telnet interface where varnish is listening to

2
npm-shrinkwrap.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "windshaft-cartodb", "name": "windshaft-cartodb",
"version": "2.11.1", "version": "2.12.0",
"dependencies": { "dependencies": {
"cartodb-psql": { "cartodb-psql": {
"version": "0.4.0", "version": "0.4.0",

View File

@ -1,7 +1,7 @@
{ {
"private": true, "private": true,
"name": "windshaft-cartodb", "name": "windshaft-cartodb",
"version": "2.11.1", "version": "2.12.0",
"description": "A map tile server for CartoDB", "description": "A map tile server for CartoDB",
"keywords": [ "keywords": [
"cartodb" "cartodb"