cloudcms-server 4.0.0-beta.2 → 4.0.0-beta.21

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 (78) hide show
  1. package/README.md +0 -5
  2. package/cloudcms-server.iml +1 -0
  3. package/index.js +58 -32
  4. package/middleware/authentication/authentication.js +40 -12
  5. package/middleware/authentication/providers/saml.js +8 -4
  6. package/middleware/awareness/awareness.js +8 -7
  7. package/middleware/awareness/plugins/api_event.js +105 -0
  8. package/middleware/awareness/plugins/editorial.js +54 -3
  9. package/middleware/awareness/plugins/resources.js +13 -5
  10. package/middleware/config/adapter.js +0 -44
  11. package/middleware/deployment/deployment.js +22 -24
  12. package/middleware/driver/driver.js +24 -1
  13. package/middleware/driver-config/driver-config.js +0 -6
  14. package/middleware/modules/modules.js +11 -5
  15. package/middleware/perf/perf.js +3 -2
  16. package/middleware/registration/registration.js +0 -5
  17. package/middleware/stores/engines/empty.js +0 -4
  18. package/middleware/stores/engines/fs-caching-adapter.js +0 -5
  19. package/middleware/stores/engines/fs.js +0 -9
  20. package/middleware/stores/engines/s3.js +0 -5
  21. package/middleware/stores/engines/s3fs.js +0 -5
  22. package/middleware/stores/multistore.js +0 -29
  23. package/middleware/stores/store.js +0 -10
  24. package/middleware/stores/stores.js +2 -2
  25. package/middleware/virtual-config/virtual-config.js +253 -206
  26. package/middleware/virtual-files/virtual-files.js +0 -3
  27. package/middleware/welcome/welcome.js +0 -3
  28. package/notifications/notifications.js +72 -10
  29. package/notifications/providers/kafka.js +182 -0
  30. package/notifications/providers/stomp.js +4 -0
  31. package/package.json +40 -56
  32. package/server/index.js +216 -123
  33. package/server/standalone.js +1 -6
  34. package/util/auth.js +10 -4
  35. package/util/cloudcms.js +77 -35
  36. package/util/loaders.js +113 -0
  37. package/util/proxy-factory.js +143 -168
  38. package/util/request.js +6 -2
  39. package/util/workqueue.js +111 -0
  40. package/.last_command +0 -7
  41. package/duster/helpers/core/cloudcms/associations.js +0 -34
  42. package/duster/helpers/core/cloudcms/beta/markdown.js +0 -46
  43. package/duster/helpers/core/cloudcms/beta/nodeAttachmentText.js +0 -46
  44. package/duster/helpers/core/cloudcms/beta/params.js +0 -33
  45. package/duster/helpers/core/cloudcms/beta/processTemplate.js +0 -82
  46. package/duster/helpers/core/cloudcms/content.js +0 -34
  47. package/duster/helpers/core/cloudcms/expand.js +0 -38
  48. package/duster/helpers/core/cloudcms/form.js +0 -34
  49. package/duster/helpers/core/cloudcms/query.js +0 -34
  50. package/duster/helpers/core/cloudcms/queryOne.js +0 -34
  51. package/duster/helpers/core/cloudcms/relatives.js +0 -34
  52. package/duster/helpers/core/cloudcms/search.js +0 -34
  53. package/duster/helpers/core/cloudcms/searchOne.js +0 -34
  54. package/duster/helpers/core/cloudcms/wcm/dependency.js +0 -83
  55. package/duster/helpers/core/cloudcms/wcm/fragment.js +0 -34
  56. package/duster/helpers/core/dev/debug.js +0 -42
  57. package/duster/helpers/core/dom/block.js +0 -49
  58. package/duster/helpers/core/dom/include.js +0 -38
  59. package/duster/helpers/core/dom/layout.js +0 -49
  60. package/duster/helpers/core/dom/link.js +0 -81
  61. package/duster/helpers/core/dom/resource.js +0 -77
  62. package/duster/helpers/core/engine.js +0 -1580
  63. package/duster/helpers/core/ice/value.js +0 -65
  64. package/duster/helpers/core/index.js +0 -49
  65. package/duster/helpers/core/operators/if.js +0 -64
  66. package/duster/helpers/core/operators/iter.js +0 -45
  67. package/duster/helpers/core/operators/iterate.js +0 -129
  68. package/duster/helpers/sample/nyt.js +0 -114
  69. package/duster/index.js +0 -319
  70. package/duster/support.js +0 -436
  71. package/duster/tracker.js +0 -262
  72. package/middleware/authentication/providers/cas.js +0 -73
  73. package/middleware/authentication/providers/facebook.js +0 -120
  74. package/middleware/authentication/providers/github.js +0 -88
  75. package/middleware/authentication/providers/linkedin.js +0 -112
  76. package/middleware/authentication/providers/twitter.js +0 -120
  77. package/middleware/server-tags/server-tags.js +0 -113
  78. package/middleware/wcm/wcm.js +0 -1437
package/server/index.js CHANGED
@@ -16,8 +16,7 @@ var session = require('express-session');
16
16
  var cookieParser = require('cookie-parser');
17
17
  var flash = require("connect-flash");
18
18
 
19
- //const redis = require('redis');
20
- const connectRedis = require('connect-redis');
19
+ const {RedisStore} = require("connect-redis");
21
20
 
22
21
  // we don't bind a single passport - instead, we get the constructor here by hand
23
22
  var Passport = require("passport").Passport;
@@ -33,11 +32,6 @@ var requestParam = require("request-param")();
33
32
  // cloudcms app server support
34
33
  var main = require("../index");
35
34
 
36
- // duster service
37
- var duster = require("../duster/index");
38
-
39
- var coreHelpers = require("../duster/helpers/core/index");
40
-
41
35
  var helmet = require("helmet");
42
36
 
43
37
  var responseTime = require("response-time");
@@ -71,7 +65,6 @@ var SETTINGS = {
71
65
  "beforeFunctions": [],
72
66
  "afterFunctions": [],
73
67
  "reportFunctions": [],
74
- "dustFunctions": [],
75
68
  "initFunctions": [],
76
69
  "filterFunctions": [],
77
70
  "driverFunctions": [],
@@ -182,11 +175,6 @@ var SETTINGS = {
182
175
  "modules": "hosts_s3fs"
183
176
  }
184
177
  },
185
- "duster": {
186
- "fragments": {
187
- "cache": true
188
- }
189
- },
190
178
  "virtualHost": {
191
179
  "enabled": false
192
180
  },
@@ -324,9 +312,6 @@ var SETTINGS = {
324
312
  }
325
313
  };
326
314
 
327
- // always push core tag helpers to the front
328
- SETTINGS.dustFunctions.unshift(coreHelpers);
329
-
330
315
  // if SETTINGS.errorFunctions is empty, plug in a default error handler
331
316
  if (SETTINGS.errorFunctions.length === 0)
332
317
  {
@@ -448,17 +433,6 @@ exports.error = function (fn) {
448
433
  SETTINGS.errorFunctions.push(fn);
449
434
  };
450
435
 
451
- /**
452
- * Adds an initialization function to set up dust.
453
- *
454
- * The function must have signature fn(app, dust)
455
- *
456
- * @param helperFn
457
- */
458
- var dust = exports.dust = function(fn) {
459
- SETTINGS.dustFunctions.push(fn);
460
- };
461
-
462
436
  /**
463
437
  * Registers a function to run before the server starts.
464
438
  *
@@ -612,12 +586,43 @@ var _start = function(overrides, callback) {
612
586
  if (!process.env.CLOUDCMS_STANDALONE_HOST) {
613
587
  process.env.CLOUDCMS_STANDALONE_HOST = "local";
614
588
  }
615
-
616
-
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
+ ///////////////////////
617
619
  // auto-configuration for HTTPS
620
+ ///////////////////////
621
+
618
622
  if (!process.configuration.https) {
619
623
  process.configuration.https = {};
620
624
  }
625
+
621
626
  if (process.env.CLOUDCMS_HTTPS) {
622
627
  process.configuration.https = JSON.parse(process.env.CLOUDCMS_HTTPS);
623
628
  }
@@ -639,13 +644,12 @@ var _start = function(overrides, callback) {
639
644
  if (process.env.CLOUDCMS_HTTPS_CA_FILEPATH) {
640
645
  process.configuration.https.ca = [ fs.readFileSync(process.env.CLOUDCMS_HTTPS_CA_FILEPATH) ];
641
646
  }
642
-
647
+
643
648
  // if https config is empty, remove it
644
649
  if (Object.keys(process.configuration.https).length === 0) {
645
650
  delete process.configuration.https;
646
651
  }
647
-
648
-
652
+
649
653
  // auto configuration of session store
650
654
  if (!process.configuration.session) {
651
655
  process.configuration.session = {};
@@ -746,8 +750,7 @@ var initSession = function(initDone)
746
750
  var IORedis = require("ioredis");
747
751
  var redisOptions = redisHelper.redisOptions();
748
752
  var redisClient = new IORedis(redisOptions.url);
749
-
750
- var RedisStore = connectRedis(session);
753
+
751
754
  sessionConfig.store = new RedisStore({ client: redisClient });
752
755
  initDone(null, session(sessionConfig));
753
756
  }
@@ -763,11 +766,54 @@ var initSession = function(initDone)
763
766
  }
764
767
  };
765
768
 
769
+ //var debugMiddleware = process.debugMiddleware;
770
+
766
771
  var startServer = function(config, startServerFinishedFn)
767
772
  {
768
773
  var app = express();
769
774
  app.disable('x-powered-by');
770
-
775
+
776
+ // customize the app use() method to provide sensible logging
777
+ app._use = app.use;
778
+ app.use = function(f)
779
+ {
780
+ if (typeof(f) !== "function")
781
+ {
782
+ return app._use.apply(app, arguments);
783
+ }
784
+
785
+ return app._use(function(f) {
786
+ return function(req, res, next)
787
+ {
788
+ var functionName = f.name;
789
+ if (!functionName) {
790
+ functionName = "unknown";
791
+ }
792
+
793
+ var id = req.id;
794
+
795
+ var startTime = process.hrtime();
796
+
797
+ f(req, res, function() {
798
+ var totalTime = process.hrtime(startTime);
799
+ var totalTimeMs = (totalTime[1] / 1000000).toFixed(2);
800
+ // if (totalTimeMs > 100)
801
+ // {
802
+ // if (id)
803
+ // {
804
+ // console.log("[" + id + "](" + functionName + ") time: " + totalTimeMs);
805
+ // }
806
+ //
807
+ // //console.trace();
808
+ // //process.exit(-1);
809
+ // }
810
+
811
+ next();
812
+ });
813
+ }
814
+ }(f));
815
+ };
816
+
771
817
  initSession(function(err, initializedSession) {
772
818
 
773
819
  if (err) {
@@ -780,6 +826,10 @@ var startServer = function(config, startServerFinishedFn)
780
826
 
781
827
  // global service starts
782
828
  main.init(app, function (err) {
829
+
830
+ if (err) {
831
+ return startServerFinishedFn(err);
832
+ }
783
833
 
784
834
  app.enable('strict routing');
785
835
 
@@ -787,7 +837,6 @@ var startServer = function(config, startServerFinishedFn)
787
837
  //
788
838
  // BASE CONFIGURATION
789
839
  //
790
- // Configures NodeJS app server using dustjs templating engine
791
840
  // Runs on port 3000 by default
792
841
  //
793
842
  ////////////////////////////////////////////////////////////////////////////
@@ -796,16 +845,7 @@ var startServer = function(config, startServerFinishedFn)
796
845
  app.set('port', process.env.PORT);
797
846
  app.set('views', process.env.CLOUDCMS_APPSERVER_BASE_PATH + "/views");
798
847
 
799
- if (config.viewEngine === "dust")
800
- {
801
- var cons = require('consolidate');
802
-
803
- app.set('view engine', 'html');
804
- app.set('view engine', 'dust');
805
- app.engine('html', cons.dust);
806
- app.engine('dust', cons.dust);
807
- }
808
- else if (config.viewEngine === "handlebars" || config.viewEngine === "hbs")
848
+ if (config.viewEngine === "handlebars" || config.viewEngine === "hbs")
809
849
  {
810
850
  var hbs = require('hbs');
811
851
 
@@ -880,7 +920,7 @@ var startServer = function(config, startServerFinishedFn)
880
920
 
881
921
  return message;
882
922
  });
883
-
923
+
884
924
  /*
885
925
  // debug headers being set
886
926
  app.use(function(req, res, next) {
@@ -892,19 +932,19 @@ var startServer = function(config, startServerFinishedFn)
892
932
  next();
893
933
  });
894
934
  */
895
-
935
+
896
936
  // increment and assign request id
897
- app.use(function (req, res, next) {
937
+ app.use(function increment_and_assign_id(req, res, next) {
898
938
  requestCounter++;
899
939
  req.id = requestCounter;
900
940
  next();
901
941
  });
902
-
942
+
903
943
  // APPLY CUSTOM INIT FUNCTIONS
904
944
  runFunctions(config.initFunctions, [app], function (err) {
905
945
 
906
946
  // retain originalUrl and originalPath since these can get modified along the way
907
- app.use(function (req, res, next) {
947
+ app.use(function retain_original_url_path(req, res, next) {
908
948
  req.originalUrl = req.url;
909
949
  req.originalPath = req.path;
910
950
  next();
@@ -914,7 +954,7 @@ var startServer = function(config, startServerFinishedFn)
914
954
  app.use(requestParam);
915
955
 
916
956
  // add req.log function
917
- app.use(function (req, res, next) {
957
+ app.use(function bind_req_log(req, res, next) {
918
958
 
919
959
  req._log = req.log = function (text/*, warn*/) {
920
960
 
@@ -952,16 +992,47 @@ var startServer = function(config, startServerFinishedFn)
952
992
  message = "\r\n**** SLOW RESPONSE ****\r\n" + message + "\r\n";
953
993
  }
954
994
  */
955
-
995
+
956
996
  console.log(message);
957
997
  };
958
998
 
959
999
  next();
960
1000
  });
1001
+
1002
+ // kills immediately based on path, headers or other detections
1003
+ app.use(function(req, res, next) {
1004
+
1005
+ var kill = false;
1006
+ if (req.path.endsWith("/env"))
1007
+ {
1008
+ kill = true;
1009
+ }
1010
+
1011
+ if (kill)
1012
+ {
1013
+ var text = "KILL, method: " + req.method + ", url: " + req.url;
1014
+ if (req.headers)
1015
+ {
1016
+ text += ", headers: " + JSON.stringify(req.headers);
1017
+ }
1018
+ if (req.query)
1019
+ {
1020
+ text += ", query: " + JSON.stringify(req.query);
1021
+ }
1022
+ console.log(text);
1023
+
1024
+ // are we being spoofed? kill the connection
1025
+ res.blocked = true;
1026
+ res.writeHead(503, { 'Content-Type': 'application/json' });
1027
+ return res.end(JSON.stringify({"error": true, "message": "Bad Request."}));
1028
+ }
1029
+
1030
+ next();
1031
+ });
961
1032
 
962
1033
  // common interceptors and config
963
1034
  main.common1(app);
964
-
1035
+
965
1036
  // general logging of requests
966
1037
  // gather statistics on response time
967
1038
  app.use(responseTime(function (req, res, time) {
@@ -989,20 +1060,28 @@ var startServer = function(config, startServerFinishedFn)
989
1060
  requestPath = util.stripQueryStringFromUrl(requestPath);
990
1061
  }
991
1062
  }
992
-
993
- req.log(req.method + " " + requestPath + " [" + res.statusCode + "] (" + time.toFixed(2) + " ms)", warn);
1063
+
1064
+ var m = "";
1065
+ if (res.blocked)
1066
+ {
1067
+ m += "*BLOCKED* ";
1068
+ }
1069
+ m += req.method + " " + requestPath + " [" + res.statusCode + "]";
1070
+ m += " (" + time.toFixed(2) + " ms)";
1071
+
1072
+ req.log(m, warn);
994
1073
  }));
995
-
1074
+
996
1075
  // set up CORS allowances
997
1076
  // this lets CORS requests float through the proxy
998
1077
  app.use(main.ensureCORS());
999
-
1078
+
1000
1079
  // set up default security headers
1001
1080
  app.use(main.ensureHeaders());
1002
-
1081
+
1003
1082
  // common interceptors and config
1004
1083
  main.common2(app);
1005
-
1084
+
1006
1085
  // APPLY CUSTOM DRIVER FUNCTIONS
1007
1086
  runFunctions(config.driverFunctions, [app], function(err) {
1008
1087
 
@@ -1014,7 +1093,7 @@ var startServer = function(config, startServerFinishedFn)
1014
1093
 
1015
1094
  // cloudcms things need to run here
1016
1095
  main.common4(app, true);
1017
-
1096
+
1018
1097
  // APPLY CUSTOM FILTER FUNCTIONS
1019
1098
  runFunctions(config.filterFunctions, [app], function (err) {
1020
1099
 
@@ -1029,7 +1108,7 @@ var startServer = function(config, startServerFinishedFn)
1029
1108
 
1030
1109
  // DEVELOPMENT BASED PERFORMANCE CACHING
1031
1110
  main.perf3(app);
1032
-
1111
+
1033
1112
  // standard body parsing + a special cloud cms body parser that makes a last ditch effort for anything
1034
1113
  // that might be JSON (regardless of content type)
1035
1114
  app.use(function (req, res, next) {
@@ -1051,7 +1130,7 @@ var startServer = function(config, startServerFinishedFn)
1051
1130
  app.use(initializedSession);
1052
1131
  app.use(flash());
1053
1132
  }
1054
-
1133
+
1055
1134
  // this is the same as calling
1056
1135
  // app.use(passport.initialize());
1057
1136
  // except we create a new passport each time and store on request to support multitenancy
@@ -1090,7 +1169,7 @@ var startServer = function(config, startServerFinishedFn)
1090
1169
  req.passport.session()(req, res, next);
1091
1170
  });
1092
1171
  }
1093
-
1172
+
1094
1173
  // welcome files
1095
1174
  main.welcome(app);
1096
1175
 
@@ -1101,13 +1180,13 @@ var startServer = function(config, startServerFinishedFn)
1101
1180
 
1102
1181
  // healthcheck middleware
1103
1182
  main.healthcheck(app);
1104
-
1183
+
1105
1184
  // APPLY CUSTOM ROUTES
1106
1185
  runFunctions(config.routeFunctions, [app], function (err) {
1107
1186
 
1108
1187
  // configure cloudcms app server handlers
1109
1188
  main.handlers(app, true);
1110
-
1189
+
1111
1190
  // register error functions
1112
1191
  runFunctions(config.errorFunctions, [app], function (err) {
1113
1192
 
@@ -1125,7 +1204,7 @@ var startServer = function(config, startServerFinishedFn)
1125
1204
  }
1126
1205
  }
1127
1206
  runFunctions(allConfigureFunctions, [app], function (err) {
1128
-
1207
+
1129
1208
  // create the server (either HTTP or HTTPS)
1130
1209
  createHttpServer(app, function(err, httpServer) {
1131
1210
 
@@ -1158,27 +1237,45 @@ var createHttpServer = function(app, done)
1158
1237
  // configure helmet to support auto-upgrade of http->https
1159
1238
  app.use(helmet());
1160
1239
  }
1161
-
1240
+
1241
+ process.configuration.https.keepAliveTimeout = process.defaultKeepAliveMs;
1242
+ process.configuration.https.requestTimeout = process.defaultKeepAliveMs;
1243
+
1162
1244
  // create https server
1245
+ console.log("Create HTTPS server");
1163
1246
  httpServer = https.createServer(process.configuration.https, app);
1164
1247
  }
1165
1248
  else
1166
1249
  {
1167
1250
  // legacy
1168
- httpServer = http.Server(app);
1251
+ //httpServer = http.Server(app);
1252
+ console.log("Create HTTP server");
1253
+ httpServer = http.createServer({
1254
+ "keepAliveTimeout": process.defaultKeepAliveMs,
1255
+ "requestTimeout": process.defaultKeepAliveMs
1256
+ }, app);
1169
1257
  }
1170
1258
 
1171
- // request timeout
1172
- var requestTimeout = 30000; // 30 seconds
1173
- if (process.configuration && process.configuration.timeout)
1174
- {
1175
- requestTimeout = process.configuration.timeout;
1176
- }
1177
- httpServer.setTimeout(requestTimeout);
1178
-
1259
+ // socket timeout
1260
+ httpServer.setTimeout(process.defaultHttpTimeoutMs, function(socket) {
1261
+ try { socket.end(); } catch (e) { }
1262
+ try { socket.destroy(); } catch (e) { }
1263
+ });
1264
+
1265
+
1266
+ var c = 0;
1267
+
1179
1268
  // socket
1180
1269
  httpServer.on("connection", function (socket) {
1270
+
1271
+ //console.log("[SOCKET CONNECTION] " + socket);
1272
+
1181
1273
  socket.setNoDelay(true);
1274
+
1275
+ socket.setTimeout(process.defaultHttpTimeoutMs, function(socket) {
1276
+ try { socket.end(); } catch (e) { }
1277
+ try { socket.destroy(); } catch (e) { }
1278
+ });
1182
1279
  });
1183
1280
 
1184
1281
  done(null, httpServer);
@@ -1274,54 +1371,50 @@ var configureServer = function(config, app, httpServer, configureServerFinishedF
1274
1371
  }
1275
1372
 
1276
1373
  // SET INITIAL VALUE FOR SERVER TIMESTAMP
1277
- process.env.CLOUDCMS_APPSERVER_TIMESTAMP = new Date().getTime();
1374
+ process.env.CLOUDCMS_APPSERVER_TIMESTAMP = Date.now();
1278
1375
 
1279
- // DUST
1280
- runFunctions(config.dustFunctions, [app, duster.getDust()], function (err) {
1281
-
1282
- // APPLY SERVER BEFORE START FUNCTIONS
1283
- runFunctions(config.beforeFunctions, [app], function (err) {
1284
-
1285
- // AFTER SERVER START
1286
- runFunctions(config.afterFunctions, [app], function (err) {
1287
-
1288
- function cleanup() {
1289
-
1290
- if (cluster.isMaster)
1291
- {
1292
- console.log("");
1293
- console.log("");
1294
-
1295
- console.log("Cloud CMS Module shutting down");
1296
-
1297
- // close server connections as cleanly as we can
1298
- console.log(" -> Closing server connections");
1299
- }
1300
-
1301
- try
1302
- {
1303
- httpServer.close();
1304
- }
1305
- catch (e)
1306
- {
1307
- console.log("Server.close produced error: " + JSON.stringify(e));
1308
- }
1309
-
1310
- if (cluster.isMaster)
1311
- {
1312
- console.log("");
1313
- }
1314
-
1315
- // tell the process to exit
1316
- process.exit();
1376
+ // APPLY SERVER BEFORE START FUNCTIONS
1377
+ runFunctions(config.beforeFunctions, [app], function (err) {
1378
+
1379
+ // AFTER SERVER START
1380
+ runFunctions(config.afterFunctions, [app], function (err) {
1381
+
1382
+ function cleanup() {
1383
+
1384
+ if (cluster.isMaster)
1385
+ {
1386
+ console.log("");
1387
+ console.log("");
1388
+
1389
+ console.log("Cloud CMS Module shutting down");
1390
+
1391
+ // close server connections as cleanly as we can
1392
+ console.log(" -> Closing server connections");
1317
1393
  }
1318
-
1319
- // listen for kill or interrupt so that we can shut down cleanly
1320
- process.on('SIGINT', cleanup);
1321
- process.on('SIGTERM', cleanup);
1322
-
1323
- configureServerFinishedFn();
1324
- });
1394
+
1395
+ try
1396
+ {
1397
+ httpServer.close();
1398
+ }
1399
+ catch (e)
1400
+ {
1401
+ console.log("Server.close produced error: " + JSON.stringify(e));
1402
+ }
1403
+
1404
+ if (cluster.isMaster)
1405
+ {
1406
+ console.log("");
1407
+ }
1408
+
1409
+ // tell the process to exit
1410
+ process.exit();
1411
+ }
1412
+
1413
+ // listen for kill or interrupt so that we can shut down cleanly
1414
+ process.on('SIGINT', cleanup);
1415
+ process.on('SIGTERM', cleanup);
1416
+
1417
+ configureServerFinishedFn();
1325
1418
  });
1326
1419
  });
1327
1420
  };
@@ -48,8 +48,8 @@ server.report(function(callback) {
48
48
  console.log("Server Base Path: " + process.env.CLOUDCMS_APPSERVER_BASE_PATH);
49
49
  console.log("Gitana Scheme: " + process.env.GITANA_PROXY_SCHEME);
50
50
  console.log("Gitana Host: " + process.env.GITANA_PROXY_HOST);
51
- console.log("Gitana Port: " + process.env.GITANA_PROXY_PORT);
52
51
  console.log("Gitana Path: " + process.env.GITANA_PROXY_PATH);
52
+ console.log("Gitana Port: " + process.env.GITANA_PROXY_PORT);
53
53
  console.log("CPU Count: " + cpuCount);
54
54
 
55
55
  var virtualHost = null;
@@ -104,11 +104,6 @@ server.start({
104
104
  },
105
105
  "insight": {
106
106
  "enabled": true
107
- },
108
- "duster": {
109
- "fragments": {
110
- "cache": true
111
- }
112
107
  }
113
108
  }, function() {
114
109
  // all done
package/util/auth.js CHANGED
@@ -324,6 +324,12 @@ var syncProfile = exports.syncProfile = function(req, res, strategy, domainId, p
324
324
  }
325
325
 
326
326
  _LOCK([CACHE_IDENTIFIER], function(err, releaseLockFn) {
327
+
328
+ if (err) {
329
+ try { releaseLockFn(); } catch (e) { }
330
+ return callback(err);
331
+ }
332
+
327
333
  _handleSyncUser(req, strategy, settings, key, domainId, providerId, providerUserId, token, refreshToken, userObject, groupsArray, function (err, gitanaUser) {
328
334
 
329
335
  if (err) {
@@ -333,14 +339,14 @@ var syncProfile = exports.syncProfile = function(req, res, strategy, domainId, p
333
339
 
334
340
  // no user found
335
341
  if (!gitanaUser) {
336
- releaseLockFn();
342
+ try { releaseLockFn(); } catch (e) { }
337
343
  return callback();
338
344
  }
339
345
 
340
346
  _handleConnectAsUser(req, key, gitanaUser, function (err, platform, appHelper, key) {
341
347
 
342
348
  if (err) {
343
- releaseLockFn();
349
+ try { releaseLockFn(); } catch (e) { }
344
350
  return callback(err);
345
351
  }
346
352
 
@@ -351,8 +357,8 @@ var syncProfile = exports.syncProfile = function(req, res, strategy, domainId, p
351
357
  "appHelper": appHelper,
352
358
  "key": key
353
359
  });
354
-
355
- releaseLockFn();
360
+
361
+ try { releaseLockFn(); } catch (e) { }
356
362
 
357
363
  callback(err, gitanaUser, platform, appHelper, key, platform.getDriver());
358
364
  }, gitanaUser);