cloudcms-server 3.3.1-beta.8 → 4.0.0-beta.1
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/LICENSE +1 -1
- package/README.md +1 -1
- package/broadcast/broadcast.js +6 -3
- package/broadcast/providers/redis.js +24 -49
- package/clients/nrp.js +117 -0
- package/clients/redis.js +64 -0
- package/d1/index.js +629 -0
- package/d1/index.js.works +203 -0
- package/d1/package.json +86 -0
- package/d1/package.json.works +14 -0
- package/duster/helpers/sample/nyt.js +2 -1
- package/framework/controllers.js +4 -4
- package/index.js +26 -14
- package/insight/insight.js +1 -1
- package/launchpad/index.js +203 -11
- package/launchpad/launchers/cluster.js +103 -110
- package/launchpad/launchers/redis.js +70 -0
- package/launchpad/launchers/single.js +36 -22
- package/locks/locks.js +63 -9
- package/locks/providers/cluster.js +3 -1
- package/locks/providers/memory.js +10 -7
- package/locks/providers/redis.js +62 -82
- package/middleware/admin/admin.js +3 -3
- package/middleware/authentication/adapters/session.js +11 -8
- package/middleware/authentication/authentication.js +28 -16
- package/middleware/authentication/authenticators/default.js +5 -2
- package/middleware/authentication/authenticators/session.js +5 -2
- package/middleware/authentication/providers/saml.js +1 -1
- package/middleware/authorization/authorization.js +11 -8
- package/middleware/awareness/awareness.js +55 -31
- package/middleware/awareness/plugins/editorial.js +4 -4
- package/middleware/awareness/providers/abstract-async.js +107 -84
- package/middleware/awareness/providers/abstract.js +1 -1
- package/middleware/awareness/providers/memory.js +0 -14
- package/middleware/awareness/providers/redis.js +186 -279
- package/middleware/cache/cache.js +4 -2
- package/middleware/cache/providers/redis.js +127 -89
- package/middleware/cache/providers/shared-memory.js +3 -3
- package/middleware/cloudcms/cloudcms.js +22 -16
- package/middleware/form/form.js +3 -3
- package/middleware/modules/modules.js +63 -10
- package/middleware/proxy/proxy.js +8 -21
- package/middleware/stores/stores.js +48 -5
- package/middleware/themes/themes.js +49 -0
- package/middleware/virtual-config/virtual-config.js +11 -8
- package/middleware/wcm/wcm.js +4 -4
- package/notifications/notifications.js +27 -4
- package/package.json +30 -25
- package/server/index.js +508 -412
- package/server/standalone.js +9 -0
- package/temp/clusterlock/index.js +3 -3
- package/temp/clusterlock/package.json +1 -1
- package/temp/passport-saml/LICENSE +23 -0
- package/temp/passport-saml/README.md +406 -0
- package/temp/passport-saml/lib/node-saml/algorithms.d.ts +5 -0
- package/temp/passport-saml/lib/node-saml/algorithms.js +41 -0
- package/temp/passport-saml/lib/node-saml/algorithms.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/index.d.ts +3 -0
- package/temp/passport-saml/lib/node-saml/index.js +6 -0
- package/temp/passport-saml/lib/node-saml/index.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.d.ts +45 -0
- package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js +86 -0
- package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/saml-post-signing.d.ts +3 -0
- package/temp/passport-saml/lib/node-saml/saml-post-signing.js +15 -0
- package/temp/passport-saml/lib/node-saml/saml-post-signing.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/saml.d.ts +77 -0
- package/temp/passport-saml/lib/node-saml/saml.js +1170 -0
- package/temp/passport-saml/lib/node-saml/saml.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/types.d.ts +95 -0
- package/temp/passport-saml/lib/node-saml/types.js +8 -0
- package/temp/passport-saml/lib/node-saml/types.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/utility.d.ts +3 -0
- package/temp/passport-saml/lib/node-saml/utility.js +19 -0
- package/temp/passport-saml/lib/node-saml/utility.js.map +1 -0
- package/temp/passport-saml/lib/node-saml/xml.d.ts +21 -0
- package/temp/passport-saml/lib/node-saml/xml.js +140 -0
- package/temp/passport-saml/lib/node-saml/xml.js.map +1 -0
- package/temp/passport-saml/lib/passport-saml/index.d.ts +6 -0
- package/temp/passport-saml/lib/passport-saml/index.js +11 -0
- package/temp/passport-saml/lib/passport-saml/index.js.map +1 -0
- package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.d.ts +13 -0
- package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js +63 -0
- package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js.map +1 -0
- package/temp/passport-saml/lib/passport-saml/strategy.d.ts +20 -0
- package/temp/passport-saml/lib/passport-saml/strategy.js +167 -0
- package/temp/passport-saml/lib/passport-saml/strategy.js.map +1 -0
- package/temp/passport-saml/lib/passport-saml/types.d.ts +51 -0
- package/temp/passport-saml/lib/passport-saml/types.js +11 -0
- package/temp/passport-saml/lib/passport-saml/types.js.map +1 -0
- package/temp/passport-saml/package.json +96 -0
- package/util/auth.js +6 -6
- package/util/cloudcms.js +85 -88
- package/util/proxy-factory.js +159 -268
- package/util/redis.js +113 -0
- package/util/renditions.js +12 -6
- package/util/request.js +48 -12
- package/util/util.js +16 -2
- package/launchpad/launchers/sticky-cluster.js +0 -43
- package/temp/memored/.jshintrc +0 -4
- package/temp/memored/README.md +0 -240
- package/temp/memored/demo/demo1.js +0 -37
- package/temp/memored/demo/demo2.js +0 -32
- package/temp/memored/gulpfile.js +0 -8
- package/temp/memored/index.js +0 -343
- package/temp/memored/package.json +0 -54
- package/temp/memored/spec/memored.spec.js +0 -265
- package/web/cms/ice.js +0 -109
- package/web/cms/preview.js +0 -106
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
var createProxyHandler = function(protocol, hostname, port, pathPrefix)
|
|
2
|
+
{
|
|
3
|
+
const proxy = require("http2-proxy");
|
|
4
|
+
const finalhandler = require('finalhandler')
|
|
5
|
+
|
|
6
|
+
const defaultWebHandler = function(err, req, res) {
|
|
7
|
+
if (err)
|
|
8
|
+
{
|
|
9
|
+
console.log("A web proxy error was caught, path: " + req.path + ", err: ", err);
|
|
10
|
+
try { res.status(500); } catch (e) { }
|
|
11
|
+
try { res.end('Something went wrong while proxying the request.'); } catch (e) { }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
finalhandler(req, res)(err);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// web
|
|
18
|
+
var webConfig = {};
|
|
19
|
+
webConfig.hostname = hostname;
|
|
20
|
+
webConfig.port = port;
|
|
21
|
+
webConfig.protocol = protocol;
|
|
22
|
+
//webConfig.path = null;
|
|
23
|
+
webConfig.timeout = 120000;
|
|
24
|
+
webConfig.proxyTimeout = 120000;
|
|
25
|
+
webConfig.proxyName = "Cloud CMS UI Proxy";
|
|
26
|
+
webConfig.onReq = function(req, options) {
|
|
27
|
+
|
|
28
|
+
if (!options.headers) {
|
|
29
|
+
options.headers = {};
|
|
30
|
+
}
|
|
31
|
+
var headers = options.headers;
|
|
32
|
+
|
|
33
|
+
if (options.path && options.path.startsWith("/proxy")) {
|
|
34
|
+
options.path = options.path.substring(6);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (pathPrefix) {
|
|
38
|
+
options.path = path.join(pathPrefix, options.path);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// used to auto-assign the client header for /oauth/token requests
|
|
42
|
+
//oauth2.autoProxy(req);
|
|
43
|
+
|
|
44
|
+
// copy domain host into "x-cloudcms-domainhost"
|
|
45
|
+
if (req.domainHost) {
|
|
46
|
+
headers["x-cloudcms-domainhost"] = req.domainHost; // this could be "localhost"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// copy virtual host into "x-cloudcms-virtualhost"
|
|
50
|
+
if (req.virtualHost) {
|
|
51
|
+
headers["x-cloudcms-virtualhost"] = req.virtualHost; // this could be "root.cloudcms.net" or "abc.cloudcms.net"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// copy deployment descriptor info
|
|
55
|
+
if (req.descriptor)
|
|
56
|
+
{
|
|
57
|
+
if (req.descriptor.tenant)
|
|
58
|
+
{
|
|
59
|
+
if (req.descriptor.tenant.id)
|
|
60
|
+
{
|
|
61
|
+
headers["x-cloudcms-tenant-id"] = req.descriptor.tenant.id;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (req.descriptor.tenant.title)
|
|
65
|
+
{
|
|
66
|
+
headers["x-cloudcms-tenant-title"] = req.descriptor.tenant.title;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (req.descriptor.application)
|
|
71
|
+
{
|
|
72
|
+
if (req.descriptor.application.id)
|
|
73
|
+
{
|
|
74
|
+
headers["x-cloudcms-application-id"] = req.descriptor.application.id;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (req.descriptor.application.title)
|
|
78
|
+
{
|
|
79
|
+
headers["x-cloudcms-application-title"] = req.descriptor.application.title;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// set optional "x-cloudcms-origin" header
|
|
85
|
+
var cloudcmsOrigin = null;
|
|
86
|
+
if (req.virtualHost)
|
|
87
|
+
{
|
|
88
|
+
cloudcmsOrigin = req.virtualHost;
|
|
89
|
+
}
|
|
90
|
+
if (cloudcmsOrigin)
|
|
91
|
+
{
|
|
92
|
+
headers["x-cloudcms-origin"] = cloudcmsOrigin;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// set x-cloudcms-server-version header
|
|
96
|
+
//headers["x-cloudcms-server-version"] = process.env.CLOUDCMS_APPSERVER_PACKAGE_VERSION;
|
|
97
|
+
|
|
98
|
+
// keep alive
|
|
99
|
+
//req.headers["connection"] = "keep-alive";
|
|
100
|
+
|
|
101
|
+
// if the incoming request didn't have an "Authorization" header
|
|
102
|
+
// and we have a logged in Gitana User via Auth, then set authorization header to Bearer Access Token
|
|
103
|
+
if (!req.headers["authorization"])
|
|
104
|
+
{
|
|
105
|
+
if (req.gitana_user)
|
|
106
|
+
{
|
|
107
|
+
headers["authorization"] = "Bearer " + req.gitana_user.getDriver().http.accessToken();
|
|
108
|
+
}
|
|
109
|
+
else if (req.gitana_proxy_access_token)
|
|
110
|
+
{
|
|
111
|
+
headers["authorization"] = "Bearer " + req.gitana_proxy_access_token;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
webConfig.onRes = function(req, res, proxyRes) {
|
|
116
|
+
|
|
117
|
+
// if (req.gitana_user)
|
|
118
|
+
// {
|
|
119
|
+
// var chunks = [];
|
|
120
|
+
//
|
|
121
|
+
// // triggers on data receive
|
|
122
|
+
// proxyRes.on('data', function(chunk) {
|
|
123
|
+
// // add received chunk to chunks array
|
|
124
|
+
// chunks.push(chunk);
|
|
125
|
+
// });
|
|
126
|
+
//
|
|
127
|
+
// proxyRes.on("end", function () {
|
|
128
|
+
//
|
|
129
|
+
// if (proxyRes.statusCode === 401)
|
|
130
|
+
// {
|
|
131
|
+
// var text = "" + Buffer.concat(chunks);
|
|
132
|
+
// if (text && (text.indexOf("invalid_token") > -1) || (text.indexOf("invalid_grant") > -1))
|
|
133
|
+
// {
|
|
134
|
+
// var identifier = req.identity_properties.provider_id + "/" + req.identity_properties.user_identifier;
|
|
135
|
+
//
|
|
136
|
+
// _LOCK([identifier], function(err, releaseLockFn) {
|
|
137
|
+
//
|
|
138
|
+
// if (err)
|
|
139
|
+
// {
|
|
140
|
+
// // failed to acquire lock
|
|
141
|
+
// console.log("FAILED TO ACQUIRE LOCK", err);
|
|
142
|
+
// req.log("FAILED TO ACQUIRE LOCK", err);
|
|
143
|
+
// try { releaseLockFn(); } catch (e) { }
|
|
144
|
+
// return;
|
|
145
|
+
// }
|
|
146
|
+
//
|
|
147
|
+
// var cleanup = function (full)
|
|
148
|
+
// {
|
|
149
|
+
// delete Gitana.APPS[req.identity_properties.token];
|
|
150
|
+
// delete Gitana.PLATFORM_CACHE[req.identity_properties.token];
|
|
151
|
+
//
|
|
152
|
+
// if (full) {
|
|
153
|
+
// auth.removeUserCacheEntry(identifier);
|
|
154
|
+
// }
|
|
155
|
+
// };
|
|
156
|
+
//
|
|
157
|
+
// // null out the access token
|
|
158
|
+
// // this will force the refresh token to be used to get a new one on the next request
|
|
159
|
+
// req.gitana_user.getDriver().http.refresh(function (err) {
|
|
160
|
+
//
|
|
161
|
+
// if (err) {
|
|
162
|
+
// cleanup(true);
|
|
163
|
+
// req.log("Invalidated auth state for gitana user: " + req.identity_properties.token);
|
|
164
|
+
// return releaseLockFn();
|
|
165
|
+
// }
|
|
166
|
+
//
|
|
167
|
+
// req.gitana_user.getDriver().reloadAuthInfo(function () {
|
|
168
|
+
// cleanup(true);
|
|
169
|
+
// req.log("Refreshed token for gitana user: " + req.identity_properties.token);
|
|
170
|
+
// releaseLockFn();
|
|
171
|
+
// });
|
|
172
|
+
// });
|
|
173
|
+
// });
|
|
174
|
+
// }
|
|
175
|
+
//
|
|
176
|
+
// }
|
|
177
|
+
// });
|
|
178
|
+
// }
|
|
179
|
+
|
|
180
|
+
//res.setHeader('x-powered-by', 'cloudcms');
|
|
181
|
+
res.writeHead(proxyRes.statusCode, proxyRes.headers)
|
|
182
|
+
proxyRes.pipe(res)
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
var proxyRequestHandler = function(req, res) {
|
|
186
|
+
proxy.web(req, res, webConfig, function(err, req, res) {
|
|
187
|
+
defaultWebHandler(err, req, res);
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
return proxyRequestHandler;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const http = require("http");
|
|
195
|
+
const server = http.createServer()
|
|
196
|
+
server.listen(3000);
|
|
197
|
+
|
|
198
|
+
var proxyRequestHandler = createProxyHandler("http", "api.default.svc.cluster.local", 80);
|
|
199
|
+
server.on('request', (req, res) => {
|
|
200
|
+
req.virtualHost = "mt85.us1.cloudcms.net";
|
|
201
|
+
|
|
202
|
+
proxyRequestHandler(req, res);
|
|
203
|
+
});
|
package/d1/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "d1",
|
|
3
|
+
"description": "D1",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@socket.io/cluster-adapter": "^0.2.0",
|
|
7
|
+
"@socket.io/redis-adapter": "^7.2.0",
|
|
8
|
+
"@socket.io/sticky": "^1.0.1",
|
|
9
|
+
"accepts": "^1.3.8",
|
|
10
|
+
"agentkeepalive": "^4.2.1",
|
|
11
|
+
"alpaca": "^1.5.27",
|
|
12
|
+
"archiver": "^1.3.0",
|
|
13
|
+
"async": "^3.2.3",
|
|
14
|
+
"async-lock": "^1.3.2",
|
|
15
|
+
"aws-sdk": "^2.1208.0",
|
|
16
|
+
"basic-auth": "^2.0.1",
|
|
17
|
+
"body-parser": "^1.20.0",
|
|
18
|
+
"bytes": "^2.5.0",
|
|
19
|
+
"canoe": "^0.3.3",
|
|
20
|
+
"clone": "^2.1.2",
|
|
21
|
+
"connect-flash": "^0.1.1",
|
|
22
|
+
"connect-multiparty": "^2.2.0",
|
|
23
|
+
"connect-redis": "^6.1.3",
|
|
24
|
+
"consolidate": "^0.14.5",
|
|
25
|
+
"cookie-parser": "^1.4.4",
|
|
26
|
+
"debug": "^2.6.9",
|
|
27
|
+
"dustjs-helpers": "1.7.4",
|
|
28
|
+
"dustjs-linkedin": "3.0.1",
|
|
29
|
+
"errorhandler": "^1.5.1",
|
|
30
|
+
"express": "^4.18.1",
|
|
31
|
+
"express-session": "^1.17.3",
|
|
32
|
+
"express-useragent": "^1.0.15",
|
|
33
|
+
"extend-with-super": "^2.0.0",
|
|
34
|
+
"finalhandler": "^1.2.0",
|
|
35
|
+
"gitana": "^1.0.322",
|
|
36
|
+
"handlebars": "^4.4.2",
|
|
37
|
+
"hbs": "^4.0.5",
|
|
38
|
+
"helmet": "^4.6.0",
|
|
39
|
+
"http2-proxy": "^5.0.53",
|
|
40
|
+
"ioredis": "4.28.5",
|
|
41
|
+
"json5": "^1.0.1",
|
|
42
|
+
"jsonwebtoken": "^8.5.1",
|
|
43
|
+
"klaw": "^1.3.1",
|
|
44
|
+
"lru-cache": "^4.1.5",
|
|
45
|
+
"marked": "^4.0.14",
|
|
46
|
+
"memorystore": "^1.6.1",
|
|
47
|
+
"mime": "^1.6.0",
|
|
48
|
+
"mkdirp": "^0.5.1",
|
|
49
|
+
"moment": "^2.24.0",
|
|
50
|
+
"morgan": "^1.9.1",
|
|
51
|
+
"object-hash": "^1.3.1",
|
|
52
|
+
"object-merge": "^2.5.1",
|
|
53
|
+
"on-headers": "^1.0.2",
|
|
54
|
+
"passport": "^0.4.0",
|
|
55
|
+
"passport-cas": "^0.0.3",
|
|
56
|
+
"passport-facebook": "^2.1.1",
|
|
57
|
+
"passport-github": "^1.1.0",
|
|
58
|
+
"passport-google-oauth": "^1.0.0",
|
|
59
|
+
"passport-linkedin": "^1.0.0",
|
|
60
|
+
"passport-local": "^1.0.0",
|
|
61
|
+
"passport-oauth": "^1.0.0",
|
|
62
|
+
"passport-saml": "^2.2.0",
|
|
63
|
+
"passport-twitter": "^0.1.5",
|
|
64
|
+
"pkginfo": "^0.4.1",
|
|
65
|
+
"random-js": "^1.0.8",
|
|
66
|
+
"recursive-readdir": "^2.2.2",
|
|
67
|
+
"redis": "^4.2.0",
|
|
68
|
+
"redlock": "4.2.0",
|
|
69
|
+
"request": "^2.88.0",
|
|
70
|
+
"request-param": "^1.0.1",
|
|
71
|
+
"response-time": "^2.3.2",
|
|
72
|
+
"semver": "^7.3.7",
|
|
73
|
+
"serve-favicon": "^2.5.0",
|
|
74
|
+
"session-file-store": "^0.2.2",
|
|
75
|
+
"sha1": "^1.1.1",
|
|
76
|
+
"socket.io": "^4.5.1",
|
|
77
|
+
"ssl-root-cas": "^1.3.1",
|
|
78
|
+
"stomp-client": "^0.9.0",
|
|
79
|
+
"targz": "^1.0.1",
|
|
80
|
+
"temp": "^0.8.3",
|
|
81
|
+
"uuid": "^3.3.2",
|
|
82
|
+
"vm2": "^3.8.4",
|
|
83
|
+
"watch": "^0.13.0",
|
|
84
|
+
"winston": "^3.3.3"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": {
|
|
3
|
+
"name": "Gitana Software, Inc.",
|
|
4
|
+
"email": "info@cloudcms.com",
|
|
5
|
+
"url": "https://www.cloudcms.com"
|
|
6
|
+
},
|
|
7
|
+
"name": "d1",
|
|
8
|
+
"description": "D1",
|
|
9
|
+
"version": "0.0.1",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"http2-proxy": "^5.0.53",
|
|
12
|
+
"finalhandler": "^1.2.0"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var request = require("../../util/request");
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Sample New York Times Events tag for Dust.
|
|
3
5
|
*
|
|
@@ -6,7 +8,6 @@
|
|
|
6
8
|
exports = module.exports = function(app, dust, callback)
|
|
7
9
|
{
|
|
8
10
|
var support = require("../support")(dust);
|
|
9
|
-
var request = require("../../util/request");
|
|
10
11
|
|
|
11
12
|
// helper functions
|
|
12
13
|
var isDefined = support.isDefined;
|
package/framework/controllers.js
CHANGED
|
@@ -162,10 +162,10 @@ var handleInvalidate = function(req, res)
|
|
|
162
162
|
// new timestamp
|
|
163
163
|
process.env.CLOUDCMS_APPSERVER_TIMESTAMP = new Date().getTime();
|
|
164
164
|
|
|
165
|
-
// update all socket clients
|
|
166
|
-
process.IO.sockets.emit("timestamp", {
|
|
167
|
-
|
|
168
|
-
});
|
|
165
|
+
// // update all socket clients
|
|
166
|
+
// process.IO.sockets.emit("timestamp", {
|
|
167
|
+
// "timestamp": process.env.CLOUDCMS_APPSERVER_TIMESTAMP
|
|
168
|
+
// });
|
|
169
169
|
|
|
170
170
|
console.log("Server timestamp regenerated");
|
|
171
171
|
|
package/index.js
CHANGED
|
@@ -34,7 +34,7 @@ process.logInfo = process.log = function(text, level)
|
|
|
34
34
|
var Gitana = require("gitana");
|
|
35
35
|
|
|
36
36
|
// default http timeout
|
|
37
|
-
process.defaultHttpTimeoutMs =
|
|
37
|
+
process.defaultHttpTimeoutMs = 60000;
|
|
38
38
|
|
|
39
39
|
if (process.env.DEFAULT_HTTP_TIMEOUT_MS)
|
|
40
40
|
{
|
|
@@ -48,26 +48,29 @@ if (process.env.DEFAULT_HTTP_TIMEOUT_MS)
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
// dns fix for Node 17 +
|
|
52
|
+
// see: https://nodejs.org/api/dns.html#dnssetdefaultresultorderorder
|
|
53
|
+
var dns = require("dns");
|
|
54
|
+
dns.setDefaultResultOrder("ipv4first");
|
|
55
|
+
|
|
51
56
|
// default agents
|
|
52
57
|
var HttpKeepAliveAgent = require('agentkeepalive');
|
|
53
58
|
var HttpsKeepAliveAgent = require('agentkeepalive').HttpsAgent;
|
|
54
59
|
http.globalAgent = new HttpKeepAliveAgent({
|
|
55
60
|
keepAlive: true,
|
|
56
|
-
keepAliveMsecs:
|
|
57
|
-
|
|
61
|
+
keepAliveMsecs: 5000,
|
|
62
|
+
maxSockets: 16000,
|
|
63
|
+
maxFreeSockets: 256,
|
|
58
64
|
timeout: process.defaultHttpTimeoutMs,
|
|
59
|
-
|
|
60
|
-
maxFreeSockets: 40,
|
|
61
|
-
rejectUnauthorized: false
|
|
65
|
+
freeSocketTimeout: 4000
|
|
62
66
|
});
|
|
63
67
|
https.globalAgent = new HttpsKeepAliveAgent({
|
|
64
68
|
keepAlive: true,
|
|
65
69
|
keepAliveMsecs: 1000,
|
|
66
|
-
|
|
70
|
+
maxSockets: 16000,
|
|
71
|
+
maxFreeSockets: 256,
|
|
67
72
|
timeout: process.defaultHttpTimeoutMs,
|
|
68
|
-
|
|
69
|
-
maxFreeSockets: 40,
|
|
70
|
-
rejectUnauthorized: false
|
|
73
|
+
freeSocketTimeout: 4000
|
|
71
74
|
});
|
|
72
75
|
|
|
73
76
|
// disable for now
|
|
@@ -126,7 +129,7 @@ exports = module.exports = function()
|
|
|
126
129
|
// TODO: this is to disable really annoying Express 3.0 deprecated's for multipart() which should hopefully
|
|
127
130
|
// TODO: be resolved soon
|
|
128
131
|
console.warn = function() {};
|
|
129
|
-
|
|
132
|
+
|
|
130
133
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
131
134
|
|
|
132
135
|
// assume app-server base path if none provided
|
|
@@ -139,6 +142,7 @@ exports = module.exports = function()
|
|
|
139
142
|
var defaultGitanaProxyScheme = "https";
|
|
140
143
|
var defaultGitanaProxyHost = "api.cloudcms.com";
|
|
141
144
|
var defaultGitanaProxyPort = 443;
|
|
145
|
+
var defaultGitanaProxyPath = "";
|
|
142
146
|
|
|
143
147
|
var gitanaJsonPath = path.join(process.env.CLOUDCMS_APPSERVER_BASE_PATH, "gitana.json");
|
|
144
148
|
if (fs.existsSync(gitanaJsonPath))
|
|
@@ -150,6 +154,7 @@ exports = module.exports = function()
|
|
|
150
154
|
|
|
151
155
|
defaultGitanaProxyHost = parsedUrl.hostname;
|
|
152
156
|
defaultGitanaProxyScheme = parsedUrl.protocol.substring(0, parsedUrl.protocol.length - 1); // remove the :
|
|
157
|
+
defaultGitanaProxyPath = parsedUrl.path;
|
|
153
158
|
|
|
154
159
|
if (parsedUrl.port)
|
|
155
160
|
{
|
|
@@ -176,10 +181,13 @@ exports = module.exports = function()
|
|
|
176
181
|
if (!process.env.GITANA_PROXY_PORT) {
|
|
177
182
|
process.env.GITANA_PROXY_PORT = defaultGitanaProxyPort;
|
|
178
183
|
}
|
|
179
|
-
|
|
184
|
+
if (!process.env.GITANA_PROXY_PATH) {
|
|
185
|
+
process.env.GITANA_PROXY_PATH = defaultGitanaProxyPath;
|
|
186
|
+
}
|
|
187
|
+
|
|
180
188
|
if (cluster.isMaster)
|
|
181
189
|
{
|
|
182
|
-
process.log("Gitana Proxy pointed to: " + util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT));
|
|
190
|
+
process.log("Gitana Proxy pointed to: " + util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH));
|
|
183
191
|
}
|
|
184
192
|
|
|
185
193
|
// all web modules are included by default
|
|
@@ -218,6 +226,7 @@ exports = module.exports = function()
|
|
|
218
226
|
var serverTags = require("./middleware/server-tags/server-tags");
|
|
219
227
|
var storeService = require("./middleware/stores/stores");
|
|
220
228
|
var templates = require("./middleware/templates/templates");
|
|
229
|
+
var themes = require("./middleware/themes/themes");
|
|
221
230
|
var virtualConfig = require("./middleware/virtual-config/virtual-config");
|
|
222
231
|
var virtualFiles = require("./middleware/virtual-files/virtual-files");
|
|
223
232
|
var wcm = require("./middleware/wcm/wcm");
|
|
@@ -502,7 +511,10 @@ exports = module.exports = function()
|
|
|
502
511
|
|
|
503
512
|
// handles calls to the templates service
|
|
504
513
|
app.use(templates.handler());
|
|
505
|
-
|
|
514
|
+
|
|
515
|
+
// handles calls to the themes service
|
|
516
|
+
app.use(themes.handler());
|
|
517
|
+
|
|
506
518
|
// handles calls to the modules service
|
|
507
519
|
app.use(modules.handler());
|
|
508
520
|
|
package/insight/insight.js
CHANGED
|
@@ -128,7 +128,7 @@ var doSend = function(callback)
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
// url over to cloud cms
|
|
131
|
-
var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/warehouses/" + warehouseId + "/interactions/_create";
|
|
131
|
+
var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/warehouses/" + warehouseId + "/interactions/_create";
|
|
132
132
|
var requestConfig = {
|
|
133
133
|
"url": URL,
|
|
134
134
|
"qs": {},
|
package/launchpad/index.js
CHANGED
|
@@ -1,17 +1,209 @@
|
|
|
1
|
-
|
|
1
|
+
const cluster = require("cluster");
|
|
2
|
+
|
|
3
|
+
// Handle uncaught exceptions...
|
|
4
|
+
process.on('uncaughtException', function(err, source) {
|
|
5
|
+
// if (err === "read ECONNRESET")
|
|
6
|
+
// {
|
|
7
|
+
// // skip
|
|
8
|
+
// }
|
|
9
|
+
// else
|
|
10
|
+
// {
|
|
11
|
+
console.log(`Launchpad - process received event 'uncaughtException': ${err}, source: ${source}`);
|
|
12
|
+
console.log(err.stack);
|
|
13
|
+
// }
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
module.exports = function(type, config, options)
|
|
2
17
|
{
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
options.setup = process.env.CLOUDCMS_LAUNCHPAD_SETUP;
|
|
18
|
+
if (!type) {
|
|
19
|
+
type = process.env.CLOUDCMS_LAUNCHPAD_SETUP;
|
|
6
20
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
21
|
+
if (!type) {
|
|
22
|
+
type = "single";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
process.env.CLOUDCMS_LAUNCHPAD_SETUP = type
|
|
26
|
+
|
|
27
|
+
var launcherFactory = require("./launchers/" + type);
|
|
28
|
+
if (!launcherFactory)
|
|
29
|
+
{
|
|
30
|
+
throw new Error("Cannot find launcher factory: " + type);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var launcher = launcherFactory(config);
|
|
34
|
+
|
|
35
|
+
var reportFn = options.report;
|
|
36
|
+
if (!reportFn) {
|
|
37
|
+
options.report = reportFn = function () {};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var completionFn = options.complete;
|
|
41
|
+
if (!completionFn) {
|
|
42
|
+
options.complete = completionFn = function(err) {
|
|
43
|
+
throw new Error(err);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var fork = true;
|
|
48
|
+
if (type === "single") {
|
|
49
|
+
fork = false;
|
|
11
50
|
}
|
|
51
|
+
|
|
52
|
+
var bindToListeningPort = function(app, httpServer)
|
|
53
|
+
{
|
|
54
|
+
var httpServerPort = -1;
|
|
55
|
+
if (app) {
|
|
56
|
+
httpServerPort = app.get("port");
|
|
57
|
+
}
|
|
58
|
+
if (httpServerPort === -1) {
|
|
59
|
+
httpServerPort = process.env.PORT;
|
|
60
|
+
}
|
|
61
|
+
if (httpServerPort === -1) {
|
|
62
|
+
httpServerPort = 3000;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
httpServer.listen(httpServerPort);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var bindSignalHandler = function()
|
|
69
|
+
{
|
|
70
|
+
var signal = false;
|
|
71
|
+
process.on('SIGINT', function() {
|
|
72
|
+
if (!signal) {
|
|
73
|
+
signal = true;
|
|
74
|
+
console.log("-------");
|
|
75
|
+
console.log("Heard SIGINT - shutting down in 10 seconds...");
|
|
76
|
+
console.log("-------");
|
|
77
|
+
setTimeout(function() { process.exit(0); }, 10000);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
process.on('SIGTERM', function() {
|
|
81
|
+
if (!signal) {
|
|
82
|
+
signal = true;
|
|
83
|
+
console.log("-------");
|
|
84
|
+
console.log("Heard SIGTERM - shutting down in 10 seconds...");
|
|
85
|
+
console.log("-------");
|
|
86
|
+
setTimeout(function() { process.exit(0); }, 10000);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
if (!fork)
|
|
92
|
+
{
|
|
93
|
+
bindSignalHandler();
|
|
94
|
+
|
|
95
|
+
return launchWorker(launcher, config, options, function(err, app, httpServer) {
|
|
96
|
+
|
|
97
|
+
if (err) {
|
|
98
|
+
return completionFn(config, err);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// bind to listening port
|
|
102
|
+
bindToListeningPort(app, httpServer);
|
|
103
|
+
|
|
104
|
+
reportFn(config);
|
|
105
|
+
completionFn(config);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else
|
|
109
|
+
{
|
|
110
|
+
// in cluster mode, we have a single master listening to the port which distributes work to the workers
|
|
111
|
+
|
|
112
|
+
if (cluster.isMaster)
|
|
113
|
+
{
|
|
114
|
+
bindSignalHandler();
|
|
115
|
+
|
|
116
|
+
return launchMaster(launcher, config, options, function(err, workers, httpServer) {
|
|
117
|
+
|
|
118
|
+
if (err) {
|
|
119
|
+
return completionFn(config, err);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
//reportFn(config);
|
|
123
|
+
completionFn(config);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
else
|
|
127
|
+
{
|
|
128
|
+
return launchWorker(launcher, config, options, function(err, app, httpServer) {
|
|
129
|
+
|
|
130
|
+
// bind to listening port
|
|
131
|
+
bindToListeningPort(app, httpServer);
|
|
132
|
+
|
|
133
|
+
completionFn(config, err);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
12
138
|
|
|
13
|
-
|
|
139
|
+
var launchMaster = function(launcher, config, options, done)
|
|
140
|
+
{
|
|
141
|
+
var createHttpServer = options.createHttpServer;
|
|
142
|
+
|
|
143
|
+
createHttpServer(null, function(err, httpServer) {
|
|
144
|
+
|
|
145
|
+
if (err) {
|
|
146
|
+
return done(err);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
launcher.startCluster(httpServer, function(err) {
|
|
150
|
+
|
|
151
|
+
if (err) {
|
|
152
|
+
return done(err);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
launcher.afterStartCluster(httpServer, function(err, workers) {
|
|
156
|
+
console.log("LaunchPad started Master: " + process.pid);
|
|
157
|
+
done(err, workers, httpServer);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
var launchWorker = function(launcher, config, options, done)
|
|
164
|
+
{
|
|
165
|
+
var startServer = options.startServer;
|
|
166
|
+
|
|
167
|
+
var configureServer = options.configureServer;
|
|
168
|
+
if (!configureServer) {
|
|
169
|
+
options.configureServer = configureServer = function(config, app, httpServer, done) {
|
|
170
|
+
done();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
startServer(config, function(err, app, httpServer) {
|
|
175
|
+
|
|
176
|
+
if (err) {
|
|
177
|
+
return done(err);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
launcher.afterStartServer(app, httpServer, function(err) {
|
|
181
|
+
|
|
182
|
+
if (err) {
|
|
183
|
+
return done(err);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
configureServer(config, app, httpServer, function(err) {
|
|
187
|
+
|
|
188
|
+
if (err) {
|
|
189
|
+
return done(err);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// if we are on a worker process, then inform the master that we completed
|
|
193
|
+
if (process.send) {
|
|
194
|
+
process.send("worker-startup");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (process.env["CLUSTER_REPORT"])
|
|
198
|
+
{
|
|
199
|
+
var reportFn = options.report;
|
|
200
|
+
reportFn(config);
|
|
201
|
+
}
|
|
14
202
|
|
|
15
|
-
|
|
16
|
-
|
|
203
|
+
console.log("LaunchPad started Worker: " + process.pid);
|
|
204
|
+
|
|
205
|
+
done(null, app, httpServer);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
});
|
|
17
209
|
};
|