cloudcms-server 3.2.280 → 3.2.283
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/index.js +0 -42
- package/locks/locks.js +6 -0
- package/package.json +1 -3
- package/server/index.js +0 -28
- package/util/proxy-factory.js +5 -72
package/index.js
CHANGED
|
@@ -48,48 +48,6 @@ 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: 1000,
|
|
57
|
-
maxSockets: 16000,
|
|
58
|
-
maxFreeSockets: 256,
|
|
59
|
-
timeout: process.defaultHttpTimeoutMs,
|
|
60
|
-
freeSocketTimeout: 30000
|
|
61
|
-
});
|
|
62
|
-
https.globalAgent = new HttpsKeepAliveAgent({
|
|
63
|
-
keepAlive: true,
|
|
64
|
-
keepAliveMsecs: 1000,
|
|
65
|
-
maxSockets: 16000,
|
|
66
|
-
maxFreeSockets: 256,
|
|
67
|
-
timeout: process.defaultHttpTimeoutMs,
|
|
68
|
-
freeSocketTimeout: 30000
|
|
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
|
-
|
|
93
51
|
// root ssl ca's
|
|
94
52
|
require("ssl-root-cas").inject();
|
|
95
53
|
|
package/locks/locks.js
CHANGED
|
@@ -85,6 +85,12 @@ exports = module.exports = function()
|
|
|
85
85
|
__log(key, "request");
|
|
86
86
|
provider.lock(key, function(err, _releaseFn) {
|
|
87
87
|
|
|
88
|
+
if (err) {
|
|
89
|
+
console.log("[LOCK: " + key + "] err: ", err);
|
|
90
|
+
try { _releaseFn(); } catch (e) { }
|
|
91
|
+
return fn(err);
|
|
92
|
+
}
|
|
93
|
+
|
|
88
94
|
// wrap the releaseFn with a wrapper that can only fire once
|
|
89
95
|
var releaseFn = function(_releaseFn)
|
|
90
96
|
{
|
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.283",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "git://github.com/gitana/cloudcms-server.git"
|
|
@@ -16,7 +16,6 @@
|
|
|
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",
|
|
20
19
|
"alpaca": "^1.5.27",
|
|
21
20
|
"archiver": "^1.3.0",
|
|
22
21
|
"async": "^3.2.3",
|
|
@@ -88,7 +87,6 @@
|
|
|
88
87
|
"stomp-client": "^0.9.0",
|
|
89
88
|
"targz": "^1.0.1",
|
|
90
89
|
"temp": "^0.8.3",
|
|
91
|
-
"toobusy-js": "^0.5.1",
|
|
92
90
|
"uuid": "^3.3.2",
|
|
93
91
|
"vm2": "^3.8.4",
|
|
94
92
|
"watch": "^0.13.0",
|
package/server/index.js
CHANGED
|
@@ -40,10 +40,6 @@ var coreHelpers = require("../duster/helpers/core/index");
|
|
|
40
40
|
|
|
41
41
|
var helmet = require("helmet");
|
|
42
42
|
|
|
43
|
-
var toobusy = require("toobusy-js");
|
|
44
|
-
toobusy.maxLag(500); // 500 ms lag in event queue, quite high but usable for now
|
|
45
|
-
toobusy.interval(250);
|
|
46
|
-
|
|
47
43
|
var responseTime = require("response-time");
|
|
48
44
|
|
|
49
45
|
// safely checks for the existence of a path
|
|
@@ -890,15 +886,6 @@ var startServer = function(config, startServerFinishedFn)
|
|
|
890
886
|
});
|
|
891
887
|
*/
|
|
892
888
|
|
|
893
|
-
// middleware which blocks requests when we're too busy
|
|
894
|
-
app.use(function(req, res, next) {
|
|
895
|
-
if (toobusy()) {
|
|
896
|
-
res.status(503).send("The web application is too busy to serve this request. Please try again.");
|
|
897
|
-
} else {
|
|
898
|
-
next();
|
|
899
|
-
}
|
|
900
|
-
});
|
|
901
|
-
|
|
902
889
|
// add req.id re
|
|
903
890
|
app.use(function (req, res, next) {
|
|
904
891
|
requestCounter++;
|
|
@@ -1313,21 +1300,6 @@ var configureServer = function(config, app, httpServer, configureServerFinishedF
|
|
|
1313
1300
|
console.log("Server.close produced error: " + JSON.stringify(e));
|
|
1314
1301
|
}
|
|
1315
1302
|
|
|
1316
|
-
// ask toobusy to shut down as cleanly as we can
|
|
1317
|
-
if (cluster.isMaster)
|
|
1318
|
-
{
|
|
1319
|
-
console.log(" -> Closing toobusy monitor");
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
try
|
|
1323
|
-
{
|
|
1324
|
-
toobusy.shutdown();
|
|
1325
|
-
}
|
|
1326
|
-
catch (e)
|
|
1327
|
-
{
|
|
1328
|
-
console.log("toobusy.shutdown produced error: " + JSON.stringify(e));
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
1303
|
if (cluster.isMaster)
|
|
1332
1304
|
{
|
|
1333
1305
|
console.log("");
|
package/util/proxy-factory.js
CHANGED
|
@@ -30,6 +30,7 @@ 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;
|
|
33
34
|
if (_cachedHandler)
|
|
34
35
|
{
|
|
35
36
|
return callback(null, _cachedHandler);
|
|
@@ -40,12 +41,15 @@ var acquireProxyHandler = exports.acquireProxyHandler = function(proxyTarget, pa
|
|
|
40
41
|
|
|
41
42
|
if (err)
|
|
42
43
|
{
|
|
44
|
+
console.log("Failed to acquire proxy handler: " + name + ", err: ", err);
|
|
45
|
+
|
|
43
46
|
// failed to acquire lock
|
|
44
47
|
return callback(err);
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
// second check to make sure another thread didn't create the handler in the meantime
|
|
48
51
|
_cachedHandler = NAMED_PROXY_HANDLERS_CACHE[name];
|
|
52
|
+
_cachedHandler = null;
|
|
49
53
|
if (_cachedHandler)
|
|
50
54
|
{
|
|
51
55
|
releaseLockFn();
|
|
@@ -53,6 +57,7 @@ var acquireProxyHandler = exports.acquireProxyHandler = function(proxyTarget, pa
|
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
// create the proxy handler and cache it into LRU cache
|
|
60
|
+
console.log("Acquiring proxy handler: " + name + ", for target: " + proxyTarget + " and prefix: " + pathPrefix);
|
|
56
61
|
_cachedHandler = createProxyHandler(proxyTarget, pathPrefix);
|
|
57
62
|
|
|
58
63
|
// store back into LRU cache
|
|
@@ -270,78 +275,6 @@ var createProxyHandler = function(proxyTarget, pathPrefix)
|
|
|
270
275
|
|
|
271
276
|
|
|
272
277
|
// cookie domain rewrite?
|
|
273
|
-
|
|
274
|
-
// // if we're using auth credentials that are picked up in SSO chain, then we listen for a 401
|
|
275
|
-
// // and if we hear it, we automatically invalidate the SSO chain so that the next request
|
|
276
|
-
// // will continue to work
|
|
277
|
-
// proxyServer.on("proxyRes", function (proxyRes, req, res) {
|
|
278
|
-
//
|
|
279
|
-
// console.log("proxyRes.1");
|
|
280
|
-
//
|
|
281
|
-
// if (req.gitana_user)
|
|
282
|
-
// {
|
|
283
|
-
// var chunks = [];
|
|
284
|
-
// // triggers on data receive
|
|
285
|
-
// proxyRes.on('data', function(chunk) {
|
|
286
|
-
// // add received chunk to chunks array
|
|
287
|
-
// chunks.push(chunk);
|
|
288
|
-
// });
|
|
289
|
-
//
|
|
290
|
-
// proxyRes.on("end", function () {
|
|
291
|
-
//
|
|
292
|
-
// console.log("proxyRes.end, code: " + proxyRes.statusCode);
|
|
293
|
-
//
|
|
294
|
-
// if (proxyRes.statusCode === 401)
|
|
295
|
-
// {
|
|
296
|
-
// var text = "" + Buffer.concat(chunks);
|
|
297
|
-
// if (text && (text.indexOf("invalid_token") > -1) || (text.indexOf("invalid_grant") > -1))
|
|
298
|
-
// {
|
|
299
|
-
// var identifier = req.identity_properties.provider_id + "/" + req.identity_properties.user_identifier;
|
|
300
|
-
//
|
|
301
|
-
// _LOCK([identifier], function(err, releaseLockFn) {
|
|
302
|
-
//
|
|
303
|
-
// if (err)
|
|
304
|
-
// {
|
|
305
|
-
// // failed to acquire lock
|
|
306
|
-
// console.log("FAILED TO ACQUIRE LOCK", err);
|
|
307
|
-
// req.log("FAILED TO ACQUIRE LOCK", err);
|
|
308
|
-
// return;
|
|
309
|
-
// }
|
|
310
|
-
//
|
|
311
|
-
// var cleanup = function (full)
|
|
312
|
-
// {
|
|
313
|
-
// delete Gitana.APPS[req.identity_properties.token];
|
|
314
|
-
// delete Gitana.PLATFORM_CACHE[req.identity_properties.token];
|
|
315
|
-
//
|
|
316
|
-
// if (full) {
|
|
317
|
-
// auth.removeUserCacheEntry(identifier);
|
|
318
|
-
// }
|
|
319
|
-
// };
|
|
320
|
-
//
|
|
321
|
-
// // null out the access token
|
|
322
|
-
// // this will force the refresh token to be used to get a new one on the next request
|
|
323
|
-
// req.gitana_user.getDriver().http.refresh(function (err) {
|
|
324
|
-
//
|
|
325
|
-
// if (err) {
|
|
326
|
-
// cleanup(true);
|
|
327
|
-
// req.log("Invalidated auth state for gitana user: " + req.identity_properties.token);
|
|
328
|
-
// releaseLockFn();
|
|
329
|
-
// return;
|
|
330
|
-
// }
|
|
331
|
-
//
|
|
332
|
-
// req.gitana_user.getDriver().reloadAuthInfo(function () {
|
|
333
|
-
// cleanup(true);
|
|
334
|
-
// req.log("Refreshed token for gitana user: " + req.identity_properties.token);
|
|
335
|
-
// releaseLockFn();
|
|
336
|
-
// });
|
|
337
|
-
// });
|
|
338
|
-
// });
|
|
339
|
-
// }
|
|
340
|
-
//
|
|
341
|
-
// }
|
|
342
|
-
// });
|
|
343
|
-
// }
|
|
344
|
-
// });
|
|
345
278
|
|
|
346
279
|
return proxyRequestHandler;
|
|
347
280
|
};
|