cloudcms-server 3.2.283 → 3.2.286
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/broadcast/broadcast.js +6 -3
- 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/index.js +42 -0
- package/launchpad/index.js +60 -31
- package/launchpad/launchers/cluster.js +1 -1
- package/locks/locks.js +4 -2
- package/middleware/awareness/awareness.js +4 -2
- package/middleware/cache/cache.js +4 -2
- package/middleware/cache/providers/shared-memory.js +3 -3
- package/package.json +5 -4
- package/server/index.js +1 -1
- package/util/proxy-factory.js +3 -4
- 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
|
@@ -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
|
+
}
|
package/index.js
CHANGED
|
@@ -48,6 +48,48 @@ if (process.env.DEFAULT_HTTP_TIMEOUT_MS)
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
// default agents
|
|
52
|
+
var HttpKeepAliveAgent = require('agentkeepalive');
|
|
53
|
+
var HttpsKeepAliveAgent = require('agentkeepalive').HttpsAgent;
|
|
54
|
+
http.globalAgent = new HttpKeepAliveAgent({
|
|
55
|
+
keepAlive: true,
|
|
56
|
+
keepAliveMsecs: 5000,
|
|
57
|
+
maxSockets: 16000,
|
|
58
|
+
maxFreeSockets: 256,
|
|
59
|
+
timeout: process.defaultHttpTimeoutMs,
|
|
60
|
+
freeSocketTimeout: 4000
|
|
61
|
+
});
|
|
62
|
+
https.globalAgent = new HttpsKeepAliveAgent({
|
|
63
|
+
keepAlive: true,
|
|
64
|
+
keepAliveMsecs: 1000,
|
|
65
|
+
maxSockets: 16000,
|
|
66
|
+
maxFreeSockets: 256,
|
|
67
|
+
timeout: process.defaultHttpTimeoutMs,
|
|
68
|
+
freeSocketTimeout: 4000
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// disable for now
|
|
72
|
+
/*
|
|
73
|
+
// report http/https socket state every minute
|
|
74
|
+
var socketReportFn = function()
|
|
75
|
+
{
|
|
76
|
+
setTimeout(function() {
|
|
77
|
+
|
|
78
|
+
var http = require("http");
|
|
79
|
+
var https = require("https");
|
|
80
|
+
|
|
81
|
+
process.log("--- START SOCKET REPORT ---");
|
|
82
|
+
process.log("[http]: " + JSON.stringify(http.globalAgent.getCurrentStatus(), null, " "));
|
|
83
|
+
process.log("[https]:" + JSON.stringify(https.globalAgent.getCurrentStatus(), null, " "));
|
|
84
|
+
process.log("--- END SOCKET REPORT ---");
|
|
85
|
+
|
|
86
|
+
socketReportFn();
|
|
87
|
+
|
|
88
|
+
}, 60 * 1000);
|
|
89
|
+
};
|
|
90
|
+
socketReportFn();
|
|
91
|
+
*/
|
|
92
|
+
|
|
51
93
|
// root ssl ca's
|
|
52
94
|
require("ssl-root-cas").inject();
|
|
53
95
|
|
package/launchpad/index.js
CHANGED
|
@@ -49,26 +49,57 @@ module.exports = function(type, config, options)
|
|
|
49
49
|
fork = false;
|
|
50
50
|
}
|
|
51
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
|
+
|
|
52
91
|
if (!fork)
|
|
53
92
|
{
|
|
93
|
+
bindSignalHandler();
|
|
94
|
+
|
|
54
95
|
return launchWorker(launcher, config, options, function(err, app, httpServer) {
|
|
55
96
|
|
|
56
97
|
if (err) {
|
|
57
98
|
return completionFn(config, err);
|
|
58
99
|
}
|
|
59
100
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// httpServerPort = app.get("port");
|
|
63
|
-
// }
|
|
64
|
-
if (httpServerPort === -1) {
|
|
65
|
-
httpServerPort = process.env.PORT;
|
|
66
|
-
}
|
|
67
|
-
if (httpServerPort === -1) {
|
|
68
|
-
httpServerPort = 3000;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
httpServer.listen(httpServerPort);
|
|
101
|
+
// bind to listening port
|
|
102
|
+
bindToListeningPort(app, httpServer);
|
|
72
103
|
|
|
73
104
|
reportFn(config);
|
|
74
105
|
completionFn(config);
|
|
@@ -76,21 +107,29 @@ module.exports = function(type, config, options)
|
|
|
76
107
|
}
|
|
77
108
|
else
|
|
78
109
|
{
|
|
110
|
+
// in cluster mode, we have a single master listening to the port which distributes work to the workers
|
|
111
|
+
|
|
79
112
|
if (cluster.isMaster)
|
|
80
113
|
{
|
|
81
|
-
|
|
114
|
+
bindSignalHandler();
|
|
115
|
+
|
|
116
|
+
return launchMaster(launcher, config, options, function(err, workers, httpServer) {
|
|
82
117
|
|
|
83
118
|
if (err) {
|
|
84
119
|
return completionFn(config, err);
|
|
85
120
|
}
|
|
86
|
-
|
|
121
|
+
|
|
87
122
|
//reportFn(config);
|
|
88
123
|
completionFn(config);
|
|
89
124
|
});
|
|
90
125
|
}
|
|
91
126
|
else
|
|
92
127
|
{
|
|
93
|
-
return launchWorker(launcher, config, options, function(err) {
|
|
128
|
+
return launchWorker(launcher, config, options, function(err, app, httpServer) {
|
|
129
|
+
|
|
130
|
+
// bind to listening port
|
|
131
|
+
bindToListeningPort(app, httpServer);
|
|
132
|
+
|
|
94
133
|
completionFn(config, err);
|
|
95
134
|
});
|
|
96
135
|
}
|
|
@@ -112,22 +151,10 @@ var launchMaster = function(launcher, config, options, done)
|
|
|
112
151
|
if (err) {
|
|
113
152
|
return done(err);
|
|
114
153
|
}
|
|
115
|
-
|
|
116
|
-
var httpServerPort = -1;
|
|
117
|
-
// if (app) {
|
|
118
|
-
// httpServerPort = app.get("port");
|
|
119
|
-
// }
|
|
120
|
-
if (httpServerPort === -1) {
|
|
121
|
-
httpServerPort = process.env.PORT;
|
|
122
|
-
}
|
|
123
|
-
if (httpServerPort === -1) {
|
|
124
|
-
httpServerPort = 3000;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
httpServer.listen(httpServerPort);
|
|
128
|
-
|
|
154
|
+
|
|
129
155
|
launcher.afterStartCluster(httpServer, function(err, workers) {
|
|
130
|
-
|
|
156
|
+
console.log("LaunchPad started Master: " + process.pid);
|
|
157
|
+
done(err, workers, httpServer);
|
|
131
158
|
});
|
|
132
159
|
});
|
|
133
160
|
});
|
|
@@ -161,7 +188,7 @@ var launchWorker = function(launcher, config, options, done)
|
|
|
161
188
|
if (err) {
|
|
162
189
|
return done(err);
|
|
163
190
|
}
|
|
164
|
-
|
|
191
|
+
|
|
165
192
|
// if we are on a worker process, then inform the master that we completed
|
|
166
193
|
if (process.send) {
|
|
167
194
|
process.send("worker-startup");
|
|
@@ -173,6 +200,8 @@ var launchWorker = function(launcher, config, options, done)
|
|
|
173
200
|
reportFn(config);
|
|
174
201
|
}
|
|
175
202
|
|
|
203
|
+
console.log("LaunchPad started Worker: " + process.pid);
|
|
204
|
+
|
|
176
205
|
done(null, app, httpServer);
|
|
177
206
|
});
|
|
178
207
|
});
|
package/locks/locks.js
CHANGED
|
@@ -39,8 +39,10 @@ exports = module.exports = function()
|
|
|
39
39
|
if (!process.env.CLOUDCMS_LOCKS_TYPE)
|
|
40
40
|
{
|
|
41
41
|
process.env.CLOUDCMS_LOCKS_TYPE = "memory";
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
|
|
43
|
+
// auto-configure
|
|
44
|
+
if (process.env.CLOUDCMS_LAUNCHPAD_SETUP === "redis")
|
|
45
|
+
{
|
|
44
46
|
process.env.CLOUDCMS_LOCKS_TYPE = "redis";
|
|
45
47
|
}
|
|
46
48
|
}
|
|
@@ -43,8 +43,10 @@ exports = module.exports = function()
|
|
|
43
43
|
if (!process.env.CLOUDCMS_AWARENESS_TYPE)
|
|
44
44
|
{
|
|
45
45
|
process.env.CLOUDCMS_AWARENESS_TYPE = "memory";
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
|
|
47
|
+
// auto-configure
|
|
48
|
+
if (process.env.CLOUDCMS_LAUNCHPAD_SETUP === "redis")
|
|
49
|
+
{
|
|
48
50
|
process.env.CLOUDCMS_AWARENESS_TYPE = "redis";
|
|
49
51
|
}
|
|
50
52
|
}
|
|
@@ -27,8 +27,10 @@ exports = module.exports = function()
|
|
|
27
27
|
if (!process.env.CLOUDCMS_CACHE_TYPE) {
|
|
28
28
|
|
|
29
29
|
process.env.CLOUDCMS_CACHE_TYPE = "memory";
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
|
|
31
|
+
// auto-configure
|
|
32
|
+
if (process.env.CLOUDCMS_LAUNCHPAD_SETUP === "redis")
|
|
33
|
+
{
|
|
32
34
|
process.env.CLOUDCMS_CACHE_TYPE = "redis";
|
|
33
35
|
}
|
|
34
36
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var path = require("path");
|
|
2
|
-
var memored = require(
|
|
1
|
+
//var path = require("path");
|
|
2
|
+
var memored = require("memored");
|
|
3
3
|
|
|
4
|
-
var cluster = require("cluster");
|
|
4
|
+
//var cluster = require("cluster");
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Shared cluster memory using memored
|
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": "3.2.
|
|
9
|
+
"version": "3.2.286",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "git://github.com/gitana/cloudcms-server.git"
|
|
@@ -16,12 +16,13 @@
|
|
|
16
16
|
"@socket.io/redis-adapter": "^7.2.0",
|
|
17
17
|
"@socket.io/sticky": "^1.0.1",
|
|
18
18
|
"accepts": "^1.3.8",
|
|
19
|
+
"agentkeepalive": "^4.2.1",
|
|
19
20
|
"alpaca": "^1.5.27",
|
|
20
21
|
"archiver": "^1.3.0",
|
|
21
22
|
"async": "^3.2.3",
|
|
22
23
|
"async-lock": "^1.3.2",
|
|
23
|
-
"aws-sdk": "^2.
|
|
24
|
-
"basic-auth": "^
|
|
24
|
+
"aws-sdk": "^2.1208.0",
|
|
25
|
+
"basic-auth": "^2.0.1",
|
|
25
26
|
"body-parser": "^1.20.0",
|
|
26
27
|
"bytes": "^2.5.0",
|
|
27
28
|
"canoe": "^0.3.3",
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
"klaw": "^1.3.1",
|
|
52
53
|
"lru-cache": "^4.1.5",
|
|
53
54
|
"marked": "^4.0.14",
|
|
55
|
+
"memored": "^1.1.1",
|
|
54
56
|
"memorystore": "^1.6.1",
|
|
55
57
|
"mime": "^1.6.0",
|
|
56
58
|
"mkdirp": "^0.5.1",
|
|
@@ -70,7 +72,6 @@
|
|
|
70
72
|
"passport-saml": "^2.2.0",
|
|
71
73
|
"passport-twitter": "^0.1.5",
|
|
72
74
|
"pkginfo": "^0.4.1",
|
|
73
|
-
"q": "^1.5.1",
|
|
74
75
|
"random-js": "^1.0.8",
|
|
75
76
|
"recursive-readdir": "^2.2.2",
|
|
76
77
|
"redis": "^4.2.0",
|
package/server/index.js
CHANGED
package/util/proxy-factory.js
CHANGED
|
@@ -30,7 +30,6 @@ var acquireProxyHandler = exports.acquireProxyHandler = function(proxyTarget, pa
|
|
|
30
30
|
// is it already in LRU cache?
|
|
31
31
|
// if so hand it back
|
|
32
32
|
var _cachedHandler = NAMED_PROXY_HANDLERS_CACHE[name];
|
|
33
|
-
_cachedHandler = null;
|
|
34
33
|
if (_cachedHandler)
|
|
35
34
|
{
|
|
36
35
|
return callback(null, _cachedHandler);
|
|
@@ -49,7 +48,6 @@ var acquireProxyHandler = exports.acquireProxyHandler = function(proxyTarget, pa
|
|
|
49
48
|
|
|
50
49
|
// second check to make sure another thread didn't create the handler in the meantime
|
|
51
50
|
_cachedHandler = NAMED_PROXY_HANDLERS_CACHE[name];
|
|
52
|
-
_cachedHandler = null;
|
|
53
51
|
if (_cachedHandler)
|
|
54
52
|
{
|
|
55
53
|
releaseLockFn();
|
|
@@ -57,7 +55,7 @@ var acquireProxyHandler = exports.acquireProxyHandler = function(proxyTarget, pa
|
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
// create the proxy handler and cache it into LRU cache
|
|
60
|
-
console.log("Acquiring proxy handler: " + name + ", for target: " + proxyTarget + " and prefix: " + pathPrefix);
|
|
58
|
+
//console.log("Acquiring proxy handler: " + name + ", for target: " + proxyTarget + " and prefix: " + pathPrefix);
|
|
61
59
|
_cachedHandler = createProxyHandler(proxyTarget, pathPrefix);
|
|
62
60
|
|
|
63
61
|
// store back into LRU cache
|
|
@@ -106,6 +104,7 @@ var createProxyHandler = function(proxyTarget, pathPrefix)
|
|
|
106
104
|
webConfig.port = port;
|
|
107
105
|
webConfig.protocol = protocol;
|
|
108
106
|
//webConfig.path = null;
|
|
107
|
+
webConfig.timeout = 120000;
|
|
109
108
|
webConfig.proxyTimeout = 120000;
|
|
110
109
|
webConfig.proxyName = "Cloud CMS UI Proxy";
|
|
111
110
|
webConfig.onReq = function(req, options) {
|
|
@@ -273,8 +272,8 @@ var createProxyHandler = function(proxyTarget, pathPrefix)
|
|
|
273
272
|
});
|
|
274
273
|
};
|
|
275
274
|
|
|
276
|
-
|
|
277
275
|
// cookie domain rewrite?
|
|
276
|
+
// not needed - this is handled intrinsically by http2-proxy
|
|
278
277
|
|
|
279
278
|
return proxyRequestHandler;
|
|
280
279
|
};
|
package/temp/memored/.jshintrc
DELETED