cloudcms-server 4.0.0-beta.10 → 4.0.0-beta.14
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.
- package/README.md +0 -5
- package/index.js +58 -32
- package/middleware/authentication/authentication.js +40 -12
- package/middleware/authentication/providers/saml.js +7 -3
- package/middleware/config/adapter.js +0 -44
- package/middleware/deployment/deployment.js +22 -24
- package/middleware/driver/driver.js +24 -1
- package/middleware/registration/registration.js +0 -5
- package/middleware/stores/engines/empty.js +0 -4
- package/middleware/stores/engines/fs-caching-adapter.js +0 -5
- package/middleware/stores/engines/fs.js +0 -9
- package/middleware/stores/engines/s3.js +0 -5
- package/middleware/stores/engines/s3fs.js +0 -5
- package/middleware/stores/multistore.js +0 -29
- package/middleware/stores/store.js +0 -9
- package/middleware/virtual-config/virtual-config.js +253 -203
- package/package.json +34 -49
- package/server/index.js +166 -111
- package/server/standalone.js +1 -6
- package/util/cloudcms.js +34 -7
- package/util/loaders.js +113 -0
- package/util/workqueue.js +100 -0
- package/duster/helpers/core/cloudcms/associations.js +0 -34
- package/duster/helpers/core/cloudcms/beta/markdown.js +0 -46
- package/duster/helpers/core/cloudcms/beta/nodeAttachmentText.js +0 -46
- package/duster/helpers/core/cloudcms/beta/params.js +0 -33
- package/duster/helpers/core/cloudcms/beta/processTemplate.js +0 -82
- package/duster/helpers/core/cloudcms/content.js +0 -34
- package/duster/helpers/core/cloudcms/expand.js +0 -38
- package/duster/helpers/core/cloudcms/form.js +0 -34
- package/duster/helpers/core/cloudcms/query.js +0 -34
- package/duster/helpers/core/cloudcms/queryOne.js +0 -34
- package/duster/helpers/core/cloudcms/relatives.js +0 -34
- package/duster/helpers/core/cloudcms/search.js +0 -34
- package/duster/helpers/core/cloudcms/searchOne.js +0 -34
- package/duster/helpers/core/cloudcms/wcm/dependency.js +0 -83
- package/duster/helpers/core/cloudcms/wcm/fragment.js +0 -34
- package/duster/helpers/core/dev/debug.js +0 -42
- package/duster/helpers/core/dom/block.js +0 -49
- package/duster/helpers/core/dom/include.js +0 -38
- package/duster/helpers/core/dom/layout.js +0 -49
- package/duster/helpers/core/dom/link.js +0 -81
- package/duster/helpers/core/dom/resource.js +0 -77
- package/duster/helpers/core/engine.js +0 -1580
- package/duster/helpers/core/ice/value.js +0 -65
- package/duster/helpers/core/index.js +0 -49
- package/duster/helpers/core/operators/if.js +0 -64
- package/duster/helpers/core/operators/iter.js +0 -45
- package/duster/helpers/core/operators/iterate.js +0 -129
- package/duster/helpers/sample/nyt.js +0 -114
- package/duster/index.js +0 -319
- package/duster/support.js +0 -436
- package/duster/tracker.js +0 -262
- package/middleware/authentication/providers/cas.js +0 -73
- package/middleware/authentication/providers/facebook.js +0 -120
- package/middleware/authentication/providers/github.js +0 -88
- package/middleware/authentication/providers/linkedin.js +0 -112
- package/middleware/authentication/providers/twitter.js +0 -120
- package/middleware/server-tags/server-tags.js +0 -113
- package/middleware/wcm/wcm.js +0 -1437
package/package.json
CHANGED
|
@@ -1,106 +1,91 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": {
|
|
3
3
|
"name": "Gitana Software, Inc.",
|
|
4
|
-
"email": "info@
|
|
5
|
-
"url": "https://
|
|
4
|
+
"email": "info@gitana.io",
|
|
5
|
+
"url": "https://gitana.io"
|
|
6
6
|
},
|
|
7
7
|
"name": "cloudcms-server",
|
|
8
8
|
"description": "Cloud CMS Application Server Module",
|
|
9
|
-
"version": "4.0.0-beta.
|
|
9
|
+
"version": "4.0.0-beta.14",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "git://github.com/gitana/cloudcms-server.git"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@socket.io/cluster-adapter": "^0.2.
|
|
16
|
-
"@socket.io/redis-adapter": "^
|
|
17
|
-
"@socket.io/sticky": "^1.0.
|
|
15
|
+
"@socket.io/cluster-adapter": "^0.2.2",
|
|
16
|
+
"@socket.io/redis-adapter": "^8.3.0",
|
|
17
|
+
"@socket.io/sticky": "^1.0.4",
|
|
18
18
|
"accepts": "^1.3.8",
|
|
19
19
|
"agentkeepalive": "^4.5.0",
|
|
20
20
|
"alpaca": "^1.5.27",
|
|
21
|
-
"archiver": "^
|
|
22
|
-
"async": "^3.2.
|
|
23
|
-
"async-lock": "^1.
|
|
24
|
-
"aws-sdk": "^2.
|
|
25
|
-
"axios": "^1.
|
|
21
|
+
"archiver": "^7.0.1",
|
|
22
|
+
"async": "^3.2.6",
|
|
23
|
+
"async-lock": "^1.4.1",
|
|
24
|
+
"aws-sdk": "^2.1692.0",
|
|
25
|
+
"axios": "^1.7.9",
|
|
26
26
|
"basic-auth": "^2.0.1",
|
|
27
|
-
"body-parser": "^1.20.
|
|
28
|
-
"bytes": "^3.1.
|
|
27
|
+
"body-parser": "^1.20.3",
|
|
28
|
+
"bytes": "^3.1.2",
|
|
29
|
+
"cacheable-lookup": "^6.1.0",
|
|
29
30
|
"canoe": "^0.3.3",
|
|
30
31
|
"clone": "^2.1.2",
|
|
31
32
|
"connect-flash": "^0.1.1",
|
|
32
33
|
"connect-multiparty": "^2.2.0",
|
|
33
|
-
"connect-redis": "^
|
|
34
|
-
"consolidate": "^0.16.0",
|
|
34
|
+
"connect-redis": "^8.0.1",
|
|
35
35
|
"cookie-parser": "^1.4.5",
|
|
36
36
|
"debug": "^4.3.1",
|
|
37
|
-
"dustjs-helpers": "^1.7.4",
|
|
38
|
-
"dustjs-linkedin": "^3.0.1",
|
|
39
37
|
"errorhandler": "^1.5.1",
|
|
40
|
-
"express": "^4.
|
|
41
|
-
"express-session": "^1.
|
|
38
|
+
"express": "^4.21.2",
|
|
39
|
+
"express-session": "^1.18.1",
|
|
42
40
|
"express-useragent": "^1.0.15",
|
|
43
|
-
"extend-with-super": "^2.0.0",
|
|
44
41
|
"fast-proxy": "^2.2.0",
|
|
45
|
-
"gitana": "^1.0.
|
|
46
|
-
"handlebars": "^4.7.
|
|
47
|
-
"hbs": "^4.
|
|
48
|
-
"helmet": "^
|
|
49
|
-
"ioredis": "4.
|
|
50
|
-
"json5": "^2.
|
|
42
|
+
"gitana": "^1.0.330",
|
|
43
|
+
"handlebars": "^4.7.8",
|
|
44
|
+
"hbs": "^4.2.0",
|
|
45
|
+
"helmet": "^8.0.0",
|
|
46
|
+
"ioredis": "5.4.1",
|
|
47
|
+
"json5": "^2.2.3",
|
|
51
48
|
"jsonwebtoken": "^9.0.2",
|
|
52
49
|
"kafkajs": "^2.2.4",
|
|
53
|
-
"klaw": "^
|
|
50
|
+
"klaw": "^4.1.0",
|
|
54
51
|
"lru-cache": "^7.14.0",
|
|
55
|
-
"marked": "^
|
|
52
|
+
"marked": "^15.0.4",
|
|
56
53
|
"memored": "^1.1.1",
|
|
57
54
|
"memorystore": "^1.6.4",
|
|
58
55
|
"mime": "^2.4.6",
|
|
59
|
-
"
|
|
60
|
-
"moment": "^2.29.1",
|
|
56
|
+
"moment": "^2.30.1",
|
|
61
57
|
"morgan": "^1.10.0",
|
|
62
|
-
"object-hash": "^
|
|
58
|
+
"object-hash": "^3.0.0",
|
|
63
59
|
"object-merge": "^2.5.1",
|
|
64
60
|
"on-headers": "^1.0.2",
|
|
65
61
|
"passport": "^0.7.0",
|
|
66
|
-
"passport-cas": "^0.1.1",
|
|
67
|
-
"passport-facebook": "^3.0.0",
|
|
68
|
-
"passport-github": "^1.1.0",
|
|
69
62
|
"passport-google-oauth": "^2.0.0",
|
|
70
|
-
"passport-linkedin": "^1.0.0",
|
|
71
63
|
"passport-local": "^1.0.0",
|
|
72
64
|
"passport-oauth": "^1.0.0",
|
|
73
|
-
"@node-saml/passport-saml": "
|
|
74
|
-
"passport-twitter": "^0.1.5",
|
|
65
|
+
"@node-saml/passport-saml": "5.0.0",
|
|
75
66
|
"pkginfo": "^0.4.1",
|
|
76
67
|
"random-js": "^2.1.0",
|
|
77
|
-
"recursive-readdir": "^2.2.
|
|
78
|
-
"redis": "^4.
|
|
68
|
+
"recursive-readdir": "^2.2.3",
|
|
69
|
+
"redis": "^4.7.0",
|
|
79
70
|
"redlock": "4.2.0",
|
|
80
71
|
"request-param": "^1.0.1",
|
|
81
|
-
"response-time": "^2.3.
|
|
82
|
-
"semver": "^7.3
|
|
72
|
+
"response-time": "^2.3.3",
|
|
73
|
+
"semver": "^7.6.3",
|
|
83
74
|
"serve-favicon": "^2.5.0",
|
|
84
75
|
"session-file-store": "^1.5.0",
|
|
85
76
|
"sha1": "^1.1.1",
|
|
86
|
-
"socket.io": "^4.
|
|
77
|
+
"socket.io": "^4.8.1",
|
|
87
78
|
"ssl-root-cas": "^1.3.1",
|
|
88
79
|
"stomp-client": "^0.9.0",
|
|
89
80
|
"targz": "^1.0.1",
|
|
90
81
|
"temp": "^0.9.4",
|
|
91
|
-
"uuid": "^
|
|
92
|
-
"vm2": "^3.9.2",
|
|
93
|
-
"watch": "^0.13.0",
|
|
82
|
+
"uuid": "^11.0.3",
|
|
94
83
|
"winston": "^3.3.3"
|
|
95
84
|
},
|
|
96
85
|
"contributors": [
|
|
97
86
|
{
|
|
98
87
|
"name": "Michael Uzquiano",
|
|
99
88
|
"email": "uzi@cloudcms.com"
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
"name": "Harry Moore",
|
|
103
|
-
"email": "harry.moore@cloudcms.com"
|
|
104
89
|
}
|
|
105
90
|
],
|
|
106
91
|
"keywords": [
|
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
|
-
|
|
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
|
*
|
|
@@ -547,6 +521,7 @@ var runFunctions = function (functions, args, callback) {
|
|
|
547
521
|
* @param callback optional callback function
|
|
548
522
|
*/
|
|
549
523
|
exports.start = function(overrides, callback) {
|
|
524
|
+
|
|
550
525
|
setTimeout(function() {
|
|
551
526
|
_start(overrides, function(err) {
|
|
552
527
|
if (callback) {
|
|
@@ -745,8 +720,7 @@ var initSession = function(initDone)
|
|
|
745
720
|
var IORedis = require("ioredis");
|
|
746
721
|
var redisOptions = redisHelper.redisOptions();
|
|
747
722
|
var redisClient = new IORedis(redisOptions.url);
|
|
748
|
-
|
|
749
|
-
var RedisStore = connectRedis(session);
|
|
723
|
+
|
|
750
724
|
sessionConfig.store = new RedisStore({ client: redisClient });
|
|
751
725
|
initDone(null, session(sessionConfig));
|
|
752
726
|
}
|
|
@@ -762,11 +736,54 @@ var initSession = function(initDone)
|
|
|
762
736
|
}
|
|
763
737
|
};
|
|
764
738
|
|
|
739
|
+
//var debugMiddleware = process.debugMiddleware;
|
|
740
|
+
|
|
765
741
|
var startServer = function(config, startServerFinishedFn)
|
|
766
742
|
{
|
|
767
743
|
var app = express();
|
|
768
744
|
app.disable('x-powered-by');
|
|
769
|
-
|
|
745
|
+
|
|
746
|
+
// customize the app use() method to provide sensible logging
|
|
747
|
+
app._use = app.use;
|
|
748
|
+
app.use = function(f)
|
|
749
|
+
{
|
|
750
|
+
if (typeof(f) !== "function")
|
|
751
|
+
{
|
|
752
|
+
return app._use.apply(app, arguments);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
return app._use(function(f) {
|
|
756
|
+
return function(req, res, next)
|
|
757
|
+
{
|
|
758
|
+
var functionName = f.name;
|
|
759
|
+
if (!functionName) {
|
|
760
|
+
functionName = "unknown";
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
var id = req.id;
|
|
764
|
+
|
|
765
|
+
var startTime = process.hrtime();
|
|
766
|
+
|
|
767
|
+
f(req, res, function() {
|
|
768
|
+
var totalTime = process.hrtime(startTime);
|
|
769
|
+
var totalTimeMs = (totalTime[1] / 1000000).toFixed(2);
|
|
770
|
+
// if (totalTimeMs > 100)
|
|
771
|
+
// {
|
|
772
|
+
// if (id)
|
|
773
|
+
// {
|
|
774
|
+
// console.log("[" + id + "](" + functionName + ") time: " + totalTimeMs);
|
|
775
|
+
// }
|
|
776
|
+
//
|
|
777
|
+
// //console.trace();
|
|
778
|
+
// //process.exit(-1);
|
|
779
|
+
// }
|
|
780
|
+
|
|
781
|
+
next();
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
}(f));
|
|
785
|
+
};
|
|
786
|
+
|
|
770
787
|
initSession(function(err, initializedSession) {
|
|
771
788
|
|
|
772
789
|
if (err) {
|
|
@@ -790,7 +807,6 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
790
807
|
//
|
|
791
808
|
// BASE CONFIGURATION
|
|
792
809
|
//
|
|
793
|
-
// Configures NodeJS app server using dustjs templating engine
|
|
794
810
|
// Runs on port 3000 by default
|
|
795
811
|
//
|
|
796
812
|
////////////////////////////////////////////////////////////////////////////
|
|
@@ -799,16 +815,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
799
815
|
app.set('port', process.env.PORT);
|
|
800
816
|
app.set('views', process.env.CLOUDCMS_APPSERVER_BASE_PATH + "/views");
|
|
801
817
|
|
|
802
|
-
if (config.viewEngine === "
|
|
803
|
-
{
|
|
804
|
-
var cons = require('consolidate');
|
|
805
|
-
|
|
806
|
-
app.set('view engine', 'html');
|
|
807
|
-
app.set('view engine', 'dust');
|
|
808
|
-
app.engine('html', cons.dust);
|
|
809
|
-
app.engine('dust', cons.dust);
|
|
810
|
-
}
|
|
811
|
-
else if (config.viewEngine === "handlebars" || config.viewEngine === "hbs")
|
|
818
|
+
if (config.viewEngine === "handlebars" || config.viewEngine === "hbs")
|
|
812
819
|
{
|
|
813
820
|
var hbs = require('hbs');
|
|
814
821
|
|
|
@@ -883,7 +890,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
883
890
|
|
|
884
891
|
return message;
|
|
885
892
|
});
|
|
886
|
-
|
|
893
|
+
|
|
887
894
|
/*
|
|
888
895
|
// debug headers being set
|
|
889
896
|
app.use(function(req, res, next) {
|
|
@@ -895,19 +902,19 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
895
902
|
next();
|
|
896
903
|
});
|
|
897
904
|
*/
|
|
898
|
-
|
|
905
|
+
|
|
899
906
|
// increment and assign request id
|
|
900
|
-
app.use(function (req, res, next) {
|
|
907
|
+
app.use(function increment_and_assign_id(req, res, next) {
|
|
901
908
|
requestCounter++;
|
|
902
909
|
req.id = requestCounter;
|
|
903
910
|
next();
|
|
904
911
|
});
|
|
905
|
-
|
|
912
|
+
|
|
906
913
|
// APPLY CUSTOM INIT FUNCTIONS
|
|
907
914
|
runFunctions(config.initFunctions, [app], function (err) {
|
|
908
915
|
|
|
909
916
|
// retain originalUrl and originalPath since these can get modified along the way
|
|
910
|
-
app.use(function (req, res, next) {
|
|
917
|
+
app.use(function retain_original_url_path(req, res, next) {
|
|
911
918
|
req.originalUrl = req.url;
|
|
912
919
|
req.originalPath = req.path;
|
|
913
920
|
next();
|
|
@@ -917,7 +924,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
917
924
|
app.use(requestParam);
|
|
918
925
|
|
|
919
926
|
// add req.log function
|
|
920
|
-
app.use(function (req, res, next) {
|
|
927
|
+
app.use(function bind_req_log(req, res, next) {
|
|
921
928
|
|
|
922
929
|
req._log = req.log = function (text/*, warn*/) {
|
|
923
930
|
|
|
@@ -955,16 +962,47 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
955
962
|
message = "\r\n**** SLOW RESPONSE ****\r\n" + message + "\r\n";
|
|
956
963
|
}
|
|
957
964
|
*/
|
|
958
|
-
|
|
965
|
+
|
|
959
966
|
console.log(message);
|
|
960
967
|
};
|
|
961
968
|
|
|
962
969
|
next();
|
|
963
970
|
});
|
|
971
|
+
|
|
972
|
+
// kills immediately based on path, headers or other detections
|
|
973
|
+
app.use(function(req, res, next) {
|
|
974
|
+
|
|
975
|
+
var kill = false;
|
|
976
|
+
if (req.path.endsWith("/env"))
|
|
977
|
+
{
|
|
978
|
+
kill = true;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
if (kill)
|
|
982
|
+
{
|
|
983
|
+
var text = "KILL, method: " + req.method + ", url: " + req.url;
|
|
984
|
+
if (req.headers)
|
|
985
|
+
{
|
|
986
|
+
text += ", headers: " + JSON.stringify(req.headers);
|
|
987
|
+
}
|
|
988
|
+
if (req.query)
|
|
989
|
+
{
|
|
990
|
+
text += ", query: " + JSON.stringify(req.query);
|
|
991
|
+
}
|
|
992
|
+
console.log(text);
|
|
993
|
+
|
|
994
|
+
// are we being spoofed? kill the connection
|
|
995
|
+
res.blocked = true;
|
|
996
|
+
res.writeHead(503, { 'Content-Type': 'application/json' });
|
|
997
|
+
return res.end(JSON.stringify({"error": true, "message": "Bad Request."}));
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
next();
|
|
1001
|
+
});
|
|
964
1002
|
|
|
965
1003
|
// common interceptors and config
|
|
966
1004
|
main.common1(app);
|
|
967
|
-
|
|
1005
|
+
|
|
968
1006
|
// general logging of requests
|
|
969
1007
|
// gather statistics on response time
|
|
970
1008
|
app.use(responseTime(function (req, res, time) {
|
|
@@ -992,20 +1030,28 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
992
1030
|
requestPath = util.stripQueryStringFromUrl(requestPath);
|
|
993
1031
|
}
|
|
994
1032
|
}
|
|
995
|
-
|
|
996
|
-
|
|
1033
|
+
|
|
1034
|
+
var m = "";
|
|
1035
|
+
if (res.blocked)
|
|
1036
|
+
{
|
|
1037
|
+
m += "*BLOCKED* ";
|
|
1038
|
+
}
|
|
1039
|
+
m += req.method + " " + requestPath + " [" + res.statusCode + "]";
|
|
1040
|
+
m += " (" + time.toFixed(2) + " ms)";
|
|
1041
|
+
|
|
1042
|
+
req.log(m, warn);
|
|
997
1043
|
}));
|
|
998
|
-
|
|
1044
|
+
|
|
999
1045
|
// set up CORS allowances
|
|
1000
1046
|
// this lets CORS requests float through the proxy
|
|
1001
1047
|
app.use(main.ensureCORS());
|
|
1002
|
-
|
|
1048
|
+
|
|
1003
1049
|
// set up default security headers
|
|
1004
1050
|
app.use(main.ensureHeaders());
|
|
1005
|
-
|
|
1051
|
+
|
|
1006
1052
|
// common interceptors and config
|
|
1007
1053
|
main.common2(app);
|
|
1008
|
-
|
|
1054
|
+
|
|
1009
1055
|
// APPLY CUSTOM DRIVER FUNCTIONS
|
|
1010
1056
|
runFunctions(config.driverFunctions, [app], function(err) {
|
|
1011
1057
|
|
|
@@ -1017,7 +1063,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1017
1063
|
|
|
1018
1064
|
// cloudcms things need to run here
|
|
1019
1065
|
main.common4(app, true);
|
|
1020
|
-
|
|
1066
|
+
|
|
1021
1067
|
// APPLY CUSTOM FILTER FUNCTIONS
|
|
1022
1068
|
runFunctions(config.filterFunctions, [app], function (err) {
|
|
1023
1069
|
|
|
@@ -1032,7 +1078,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1032
1078
|
|
|
1033
1079
|
// DEVELOPMENT BASED PERFORMANCE CACHING
|
|
1034
1080
|
main.perf3(app);
|
|
1035
|
-
|
|
1081
|
+
|
|
1036
1082
|
// standard body parsing + a special cloud cms body parser that makes a last ditch effort for anything
|
|
1037
1083
|
// that might be JSON (regardless of content type)
|
|
1038
1084
|
app.use(function (req, res, next) {
|
|
@@ -1054,7 +1100,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1054
1100
|
app.use(initializedSession);
|
|
1055
1101
|
app.use(flash());
|
|
1056
1102
|
}
|
|
1057
|
-
|
|
1103
|
+
|
|
1058
1104
|
// this is the same as calling
|
|
1059
1105
|
// app.use(passport.initialize());
|
|
1060
1106
|
// except we create a new passport each time and store on request to support multitenancy
|
|
@@ -1093,7 +1139,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1093
1139
|
req.passport.session()(req, res, next);
|
|
1094
1140
|
});
|
|
1095
1141
|
}
|
|
1096
|
-
|
|
1142
|
+
|
|
1097
1143
|
// welcome files
|
|
1098
1144
|
main.welcome(app);
|
|
1099
1145
|
|
|
@@ -1104,13 +1150,13 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1104
1150
|
|
|
1105
1151
|
// healthcheck middleware
|
|
1106
1152
|
main.healthcheck(app);
|
|
1107
|
-
|
|
1153
|
+
|
|
1108
1154
|
// APPLY CUSTOM ROUTES
|
|
1109
1155
|
runFunctions(config.routeFunctions, [app], function (err) {
|
|
1110
1156
|
|
|
1111
1157
|
// configure cloudcms app server handlers
|
|
1112
1158
|
main.handlers(app, true);
|
|
1113
|
-
|
|
1159
|
+
|
|
1114
1160
|
// register error functions
|
|
1115
1161
|
runFunctions(config.errorFunctions, [app], function (err) {
|
|
1116
1162
|
|
|
@@ -1128,7 +1174,7 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
1128
1174
|
}
|
|
1129
1175
|
}
|
|
1130
1176
|
runFunctions(allConfigureFunctions, [app], function (err) {
|
|
1131
|
-
|
|
1177
|
+
|
|
1132
1178
|
// create the server (either HTTP or HTTPS)
|
|
1133
1179
|
createHttpServer(app, function(err, httpServer) {
|
|
1134
1180
|
|
|
@@ -1172,16 +1218,29 @@ var createHttpServer = function(app, done)
|
|
|
1172
1218
|
}
|
|
1173
1219
|
|
|
1174
1220
|
// request timeout
|
|
1175
|
-
var requestTimeout =
|
|
1221
|
+
var requestTimeout = 120000; // 2 minutes
|
|
1176
1222
|
if (process.configuration && process.configuration.timeout)
|
|
1177
1223
|
{
|
|
1178
1224
|
requestTimeout = process.configuration.timeout;
|
|
1179
1225
|
}
|
|
1180
|
-
httpServer.setTimeout(requestTimeout)
|
|
1181
|
-
|
|
1226
|
+
httpServer.setTimeout(requestTimeout, function(socket) {
|
|
1227
|
+
try { socket.end(); } catch (e) { }
|
|
1228
|
+
try { socket.destroy(); } catch (e) { }
|
|
1229
|
+
});
|
|
1230
|
+
|
|
1231
|
+
var c = 0;
|
|
1232
|
+
|
|
1182
1233
|
// socket
|
|
1183
1234
|
httpServer.on("connection", function (socket) {
|
|
1235
|
+
|
|
1236
|
+
//console.log("[SOCKET CONNECTION] " + socket);
|
|
1237
|
+
|
|
1184
1238
|
socket.setNoDelay(true);
|
|
1239
|
+
|
|
1240
|
+
socket.setTimeout(requestTimeout, function(socket) {
|
|
1241
|
+
try { socket.end(); } catch (e) { }
|
|
1242
|
+
try { socket.destroy(); } catch (e) { }
|
|
1243
|
+
});
|
|
1185
1244
|
});
|
|
1186
1245
|
|
|
1187
1246
|
done(null, httpServer);
|
|
@@ -1277,54 +1336,50 @@ var configureServer = function(config, app, httpServer, configureServerFinishedF
|
|
|
1277
1336
|
}
|
|
1278
1337
|
|
|
1279
1338
|
// SET INITIAL VALUE FOR SERVER TIMESTAMP
|
|
1280
|
-
process.env.CLOUDCMS_APPSERVER_TIMESTAMP =
|
|
1339
|
+
process.env.CLOUDCMS_APPSERVER_TIMESTAMP = Date.now();
|
|
1281
1340
|
|
|
1282
|
-
//
|
|
1283
|
-
runFunctions(config.
|
|
1284
|
-
|
|
1285
|
-
//
|
|
1286
|
-
runFunctions(config.
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
// close server connections as cleanly as we can
|
|
1301
|
-
console.log(" -> Closing server connections");
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
try
|
|
1305
|
-
{
|
|
1306
|
-
httpServer.close();
|
|
1307
|
-
}
|
|
1308
|
-
catch (e)
|
|
1309
|
-
{
|
|
1310
|
-
console.log("Server.close produced error: " + JSON.stringify(e));
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
if (cluster.isMaster)
|
|
1314
|
-
{
|
|
1315
|
-
console.log("");
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
// tell the process to exit
|
|
1319
|
-
process.exit();
|
|
1341
|
+
// APPLY SERVER BEFORE START FUNCTIONS
|
|
1342
|
+
runFunctions(config.beforeFunctions, [app], function (err) {
|
|
1343
|
+
|
|
1344
|
+
// AFTER SERVER START
|
|
1345
|
+
runFunctions(config.afterFunctions, [app], function (err) {
|
|
1346
|
+
|
|
1347
|
+
function cleanup() {
|
|
1348
|
+
|
|
1349
|
+
if (cluster.isMaster)
|
|
1350
|
+
{
|
|
1351
|
+
console.log("");
|
|
1352
|
+
console.log("");
|
|
1353
|
+
|
|
1354
|
+
console.log("Cloud CMS Module shutting down");
|
|
1355
|
+
|
|
1356
|
+
// close server connections as cleanly as we can
|
|
1357
|
+
console.log(" -> Closing server connections");
|
|
1320
1358
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1359
|
+
|
|
1360
|
+
try
|
|
1361
|
+
{
|
|
1362
|
+
httpServer.close();
|
|
1363
|
+
}
|
|
1364
|
+
catch (e)
|
|
1365
|
+
{
|
|
1366
|
+
console.log("Server.close produced error: " + JSON.stringify(e));
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
if (cluster.isMaster)
|
|
1370
|
+
{
|
|
1371
|
+
console.log("");
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
// tell the process to exit
|
|
1375
|
+
process.exit();
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
// listen for kill or interrupt so that we can shut down cleanly
|
|
1379
|
+
process.on('SIGINT', cleanup);
|
|
1380
|
+
process.on('SIGTERM', cleanup);
|
|
1381
|
+
|
|
1382
|
+
configureServerFinishedFn();
|
|
1328
1383
|
});
|
|
1329
1384
|
});
|
|
1330
1385
|
};
|
package/server/standalone.js
CHANGED
|
@@ -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
|