cloudcms-server 4.0.0-beta.16 → 4.0.0-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server/index.js +50 -16
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "name": "cloudcms-server",
8
8
  "description": "Cloud CMS Application Server Module",
9
- "version": "4.0.0-beta.16",
9
+ "version": "4.0.0-beta.17",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git://github.com/gitana/cloudcms-server.git"
package/server/index.js CHANGED
@@ -586,12 +586,55 @@ var _start = function(overrides, callback) {
586
586
  if (!process.env.CLOUDCMS_STANDALONE_HOST) {
587
587
  process.env.CLOUDCMS_STANDALONE_HOST = "local";
588
588
  }
589
-
590
-
589
+
590
+ // http timeout
591
+ // default http timeout (2 minutes)
592
+ process.defaultHttpTimeoutMs = 2 * 60 * 1000;
593
+ if (process.env.DEFAULT_HTTP_TIMEOUT_MS)
594
+ {
595
+ try {
596
+ process.defaultHttpTimeoutMs = parseInt(process.env.DEFAULT_HTTP_TIMEOUT_MS);
597
+ } catch (e) { }
598
+ }
599
+ else if (process.configuration.timeout)
600
+ {
601
+ process.defaultHttpTimeoutMs = process.configuration.timeout;
602
+ }
603
+
604
+ // socket keep alive (3 minutes)
605
+ process.defaultKeepAliveMs = (3 * 60 * 1000);
606
+ if (process.env.DEFAULT_KEEP_ALIVE_MS)
607
+ {
608
+ try {
609
+ process.defaultKeepAliveMs = parseInt(process.env.DEFAULT_KEEP_ALIVE_MS);
610
+ } catch (e) { }
611
+ }
612
+ else if (process.configuration.keepAliveMs)
613
+ {
614
+ process.defaultKeepAliveMs = process.configuration.keepAliveMs;
615
+ }
616
+
617
+
618
+ ///////////////////////
619
+ // auto-configuration for HTTP
620
+ ///////////////////////
621
+
622
+ if (!process.configuration.http) {
623
+ process.configuration.http = {};
624
+ }
625
+ process.configuration.http.keepAliveTimeout = process.defaultKeepAliveMs;
626
+ process.configuration.http.requestTimeout = process.defaultKeepAliveMs;
627
+
628
+ ///////////////////////
591
629
  // auto-configuration for HTTPS
630
+ ///////////////////////
631
+
592
632
  if (!process.configuration.https) {
593
633
  process.configuration.https = {};
594
634
  }
635
+ process.configuration.https.keepAliveTimeout = process.defaultKeepAliveMs;
636
+ process.configuration.https.requestTimeout = process.defaultKeepAliveMs;
637
+
595
638
  if (process.env.CLOUDCMS_HTTPS) {
596
639
  process.configuration.https = JSON.parse(process.env.CLOUDCMS_HTTPS);
597
640
  }
@@ -614,12 +657,6 @@ var _start = function(overrides, callback) {
614
657
  process.configuration.https.ca = [ fs.readFileSync(process.env.CLOUDCMS_HTTPS_CA_FILEPATH) ];
615
658
  }
616
659
 
617
- // if https config is empty, remove it
618
- if (Object.keys(process.configuration.https).length === 0) {
619
- delete process.configuration.https;
620
- }
621
-
622
-
623
660
  // auto configuration of session store
624
661
  if (!process.configuration.session) {
625
662
  process.configuration.session = {};
@@ -1214,20 +1251,17 @@ var createHttpServer = function(app, done)
1214
1251
  else
1215
1252
  {
1216
1253
  // legacy
1217
- httpServer = http.Server(app);
1254
+ //httpServer = http.Server(app);
1255
+ httpServer = http.createServer(process.configuration.http, app);
1218
1256
  }
1219
1257
 
1220
- // request timeout
1221
- var requestTimeout = 120000; // 2 minutes
1222
- if (process.configuration && process.configuration.timeout)
1223
- {
1224
- requestTimeout = process.configuration.timeout;
1225
- }
1226
- httpServer.setTimeout(requestTimeout, function(socket) {
1258
+ // socket timeout
1259
+ httpServer.setTimeout(process.defaultHttpTimeoutMs, function(socket) {
1227
1260
  try { socket.end(); } catch (e) { }
1228
1261
  try { socket.destroy(); } catch (e) { }
1229
1262
  });
1230
1263
 
1264
+
1231
1265
  var c = 0;
1232
1266
 
1233
1267
  // socket