cloudcms-server 0.9.267 → 0.9.271
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/launchpad/launchers/cluster.js +11 -14
- package/launchpad/launchers/redis.js +40 -54
- package/locks/providers/cluster.js +2 -0
- package/middleware/awareness/providers/abstract-async.js +3 -26
- package/middleware/proxy/proxy.js +5 -9
- package/package.json +4 -4
- package/server/index.js +6 -10
- package/server/standalone.js +3 -0
- package/temp/http-proxy/.auto-changelog +6 -0
- package/temp/http-proxy/.gitattributes +1 -0
- package/temp/http-proxy/CHANGELOG.md +1872 -0
- package/temp/http-proxy/CODE_OF_CONDUCT.md +74 -0
- package/temp/http-proxy/LICENSE +23 -0
- package/temp/http-proxy/README.md +568 -0
- package/temp/http-proxy/codecov.yml +10 -0
- package/temp/http-proxy/index.js +13 -0
- package/temp/http-proxy/lib/http-proxy/common.js +220 -0
- package/temp/http-proxy/lib/http-proxy/index.js +174 -0
- package/temp/http-proxy/lib/http-proxy/passes/web-incoming.js +174 -0
- package/temp/http-proxy/lib/http-proxy/passes/web-outgoing.js +135 -0
- package/temp/http-proxy/lib/http-proxy/passes/ws-incoming.js +141 -0
- package/temp/http-proxy/lib/index.js +13 -0
- package/temp/http-proxy/package.json +41 -0
- package/temp/http-proxy/renovate.json +19 -0
- package/temp/node-http-proxy/.eslintignore +3 -0
- package/temp/node-http-proxy/.eslintrc.js +21 -0
- package/temp/node-http-proxy/.github/workflows/ci.yml +30 -0
- package/temp/node-http-proxy/.prettierrc +7 -0
- package/temp/node-http-proxy/CODE_OF_CONDUCT.md +74 -0
- package/temp/node-http-proxy/LICENSE +23 -0
- package/temp/node-http-proxy/README.md +568 -0
- package/temp/node-http-proxy/codecov.yml +10 -0
- package/temp/node-http-proxy/dist/http-proxy/common.js +220 -0
- package/temp/node-http-proxy/dist/http-proxy/index.js +174 -0
- package/temp/node-http-proxy/dist/http-proxy/passes/web-incoming.js +174 -0
- package/temp/node-http-proxy/dist/http-proxy/passes/web-outgoing.js +135 -0
- package/temp/node-http-proxy/dist/http-proxy/passes/ws-incoming.js +141 -0
- package/temp/node-http-proxy/dist/index.js +13 -0
- package/temp/node-http-proxy/lib/http-proxy/common.js +265 -0
- package/temp/node-http-proxy/lib/http-proxy/index.ts +242 -0
- package/temp/node-http-proxy/lib/http-proxy/passes/web-incoming.js +208 -0
- package/temp/node-http-proxy/lib/http-proxy/passes/web-outgoing.js +163 -0
- package/temp/node-http-proxy/lib/http-proxy/passes/ws-incoming.js +179 -0
- package/temp/node-http-proxy/lib/index.ts +13 -0
- package/temp/node-http-proxy/lib/types.d.ts +277 -0
- package/temp/node-http-proxy/package-lock.json +5028 -0
- package/temp/node-http-proxy/package.json +47 -0
- package/temp/node-http-proxy/tsconfig.build.json +4 -0
- package/temp/node-http-proxy/tsconfig.json +115 -0
- package/temp/node-http-proxy/vitest.config.ts +9 -0
- package/util/proxy-factory.js +39 -128
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
var clusterlock = require("../../temp/clusterlock");
|
|
2
|
-
|
|
3
1
|
const cluster = require("cluster");
|
|
4
2
|
const { Server } = require("socket.io");
|
|
5
|
-
const numCPUs = require("os").cpus().length;
|
|
6
3
|
const { setupMaster, setupWorker } = require("@socket.io/sticky");
|
|
7
4
|
const { createAdapter, setupPrimary } = require("@socket.io/cluster-adapter");
|
|
8
5
|
|
|
9
|
-
// numCPUs = 1;
|
|
10
|
-
// console.log("FORCE ONE CPU");
|
|
11
|
-
|
|
12
6
|
module.exports = function(config) {
|
|
13
7
|
|
|
14
8
|
var r = {};
|
|
@@ -17,27 +11,30 @@ module.exports = function(config) {
|
|
|
17
11
|
{
|
|
18
12
|
// setup sticky sessions
|
|
19
13
|
setupMaster(httpServer, {
|
|
20
|
-
loadBalancingMethod: "least-connection"
|
|
14
|
+
//loadBalancingMethod: "least-connection"
|
|
15
|
+
loadBalancingMethod: "round-robin"
|
|
21
16
|
});
|
|
22
17
|
|
|
23
18
|
// setup connections between the workers
|
|
24
19
|
setupPrimary();
|
|
25
20
|
|
|
26
21
|
// needed for packets containing buffers
|
|
27
|
-
cluster.setupPrimary({
|
|
28
|
-
|
|
29
|
-
});
|
|
22
|
+
// cluster.setupPrimary({
|
|
23
|
+
// serialization: "advanced"
|
|
24
|
+
// });
|
|
30
25
|
|
|
31
26
|
return callback();
|
|
32
27
|
};
|
|
33
28
|
|
|
34
29
|
r.afterStartCluster = function(httpServer, callback)
|
|
35
30
|
{
|
|
36
|
-
// start up cluster locks
|
|
37
|
-
clusterlock.setup();
|
|
38
|
-
|
|
39
31
|
var startupCount = 0;
|
|
40
|
-
|
|
32
|
+
|
|
33
|
+
var numCPUs = require("os").cpus().length;
|
|
34
|
+
if (process.env.FORCE_SINGLE_CPU) {
|
|
35
|
+
numCPUs = 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
41
38
|
var workers = [];
|
|
42
39
|
for (let i = 0; i < numCPUs; i++)
|
|
43
40
|
{
|
|
@@ -2,6 +2,7 @@ const { Server } = require("socket.io");
|
|
|
2
2
|
const { setupWorker } = require("@socket.io/sticky");
|
|
3
3
|
const { createAdapter } = require("@socket.io/redis-adapter");
|
|
4
4
|
const redisHelper = require("../../util/redis");
|
|
5
|
+
const IORedis = require("ioredis");
|
|
5
6
|
|
|
6
7
|
const clusterLauncherFactory = require("./cluster");
|
|
7
8
|
|
|
@@ -23,61 +24,46 @@ module.exports = function(config) {
|
|
|
23
24
|
|
|
24
25
|
r.afterStartServer = function(app, httpServer, callback)
|
|
25
26
|
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// use the redis adapter
|
|
55
|
-
io.adapter(createAdapter(pubClient, subClient, {
|
|
56
|
-
//publishOnSpecificResponseChannel: true
|
|
57
|
-
}));
|
|
58
|
-
|
|
59
|
-
// setup connection with the primary process
|
|
60
|
-
setupWorker(io);
|
|
61
|
-
|
|
62
|
-
// on connect
|
|
63
|
-
io.on("connection", (socket) => {
|
|
64
|
-
//console.log("Redis Launcher on('connection') - socket id:" + socket.id);
|
|
65
|
-
// socket.on('message', function(m) {
|
|
66
|
-
// console.log("Socket Connection message: " + m);
|
|
67
|
-
// });
|
|
68
|
-
//
|
|
69
|
-
// // always catch err
|
|
70
|
-
// socket.on("error", function(err) {
|
|
71
|
-
// console.log("Caught socket error");
|
|
72
|
-
// console.log(err.stack);
|
|
73
|
-
// });
|
|
74
|
-
|
|
75
|
-
// TODO
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
return callback();
|
|
27
|
+
var redisOptions = redisHelper.redisOptions({}, "CLOUDCMS_CLUSTER");
|
|
28
|
+
var pubClient = new IORedis(redisOptions.url);
|
|
29
|
+
var subClient = pubClient.duplicate();
|
|
30
|
+
|
|
31
|
+
const io = new Server(httpServer);
|
|
32
|
+
httpServer.io = io;
|
|
33
|
+
|
|
34
|
+
io.engine.on("connection_error", function(err) {
|
|
35
|
+
// console.log("CONNECTION ERROR");
|
|
36
|
+
// console.log("REQUEST: ", err.req); // the request object
|
|
37
|
+
// console.log("CODE: " + err.code); // the error code, for example 1
|
|
38
|
+
// console.log("MESSAGE: ", err.message); // the error message, for example "Session ID unknown"
|
|
39
|
+
// console.log("CONTEXT: ", err.context); // some additional error context
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// use the redis adapter
|
|
43
|
+
io.adapter(createAdapter(pubClient, subClient, {
|
|
44
|
+
//publishOnSpecificResponseChannel: true
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
// setup connection with the primary process
|
|
48
|
+
setupWorker(io);
|
|
49
|
+
|
|
50
|
+
// on connect
|
|
51
|
+
io.on("connection", (socket) => {
|
|
52
|
+
//console.log("Redis Launcher on('connection') - socket id:" + socket.id);
|
|
53
|
+
socket.on('message', function(m) {
|
|
54
|
+
console.log("Socket Connection message: " + m);
|
|
79
55
|
});
|
|
80
|
-
|
|
56
|
+
|
|
57
|
+
// always catch err
|
|
58
|
+
socket.on("error", function(err) {
|
|
59
|
+
console.log("Caught socket error");
|
|
60
|
+
console.log(err.stack);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// TODO
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return callback();
|
|
81
67
|
};
|
|
82
68
|
|
|
83
69
|
return r;
|
|
@@ -52,21 +52,13 @@ class AbstractAsyncProvider extends AbstractProvider
|
|
|
52
52
|
{
|
|
53
53
|
var self = this;
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// console.log("a2: ", err);
|
|
58
|
-
// console.log("a3: ", releaseLockFn);
|
|
59
|
-
self.doRegister(channelId, user, function(err) {
|
|
60
|
-
// console.log("a4 ", err);
|
|
61
|
-
callback(err);
|
|
62
|
-
// console.log("a5: ", releaseLockFn);
|
|
63
|
-
return releaseLockFn();
|
|
64
|
-
});
|
|
55
|
+
self.doRegister(channelId, user, function(err) {
|
|
56
|
+
callback(err);
|
|
65
57
|
});
|
|
66
58
|
}
|
|
67
59
|
|
|
68
60
|
/**
|
|
69
|
-
* Workhorse method.
|
|
61
|
+
* Workhorse method.
|
|
70
62
|
*
|
|
71
63
|
* @param channelId
|
|
72
64
|
* @param user
|
|
@@ -163,21 +155,6 @@ class AbstractAsyncProvider extends AbstractProvider
|
|
|
163
155
|
{
|
|
164
156
|
var self = this;
|
|
165
157
|
|
|
166
|
-
self._lock("channels", function(err, releaseLockFn) {
|
|
167
|
-
self._expire(beforeMs, function(err) {
|
|
168
|
-
callback(err);
|
|
169
|
-
return releaseLockFn();
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @override
|
|
176
|
-
*/
|
|
177
|
-
_expire(beforeMs, callback)
|
|
178
|
-
{
|
|
179
|
-
var self = this;
|
|
180
|
-
|
|
181
158
|
self.listChannelIds(function(err, channelIds) {
|
|
182
159
|
|
|
183
160
|
if (err) {
|
|
@@ -82,20 +82,17 @@ exports = module.exports = function()
|
|
|
82
82
|
contentStore.existsFile(filePath, function(exists) {
|
|
83
83
|
|
|
84
84
|
if (!exists) {
|
|
85
|
-
callback();
|
|
86
|
-
return;
|
|
85
|
+
return callback();
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
contentStore.fileStats(filePath, function(err, stats) {
|
|
90
89
|
|
|
91
90
|
if (err) {
|
|
92
|
-
callback();
|
|
93
|
-
return;
|
|
91
|
+
return callback();
|
|
94
92
|
}
|
|
95
93
|
|
|
96
|
-
if (stats.size
|
|
97
|
-
callback();
|
|
98
|
-
return;
|
|
94
|
+
if (stats.size === 0) {
|
|
95
|
+
return callback();
|
|
99
96
|
}
|
|
100
97
|
|
|
101
98
|
var handleGoodStream = function()
|
|
@@ -117,8 +114,7 @@ exports = module.exports = function()
|
|
|
117
114
|
// check cacheInfo for expireTime
|
|
118
115
|
contentStore.readFile(filePath + ".cache", function(err, cacheInfoText) {
|
|
119
116
|
|
|
120
|
-
if (err || !cacheInfoText)
|
|
121
|
-
{
|
|
117
|
+
if (err || !cacheInfoText) {
|
|
122
118
|
return handleBadStream();
|
|
123
119
|
}
|
|
124
120
|
|
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": "0.9.
|
|
9
|
+
"version": "0.9.271",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "git://github.com/gitana/cloudcms-server.git"
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"dustjs-linkedin": "^3.0.1",
|
|
38
38
|
"errorhandler": "^1.5.1",
|
|
39
39
|
"express": "^4.17.1",
|
|
40
|
-
"express-session": "^1.
|
|
40
|
+
"express-session": "^1.17.3",
|
|
41
41
|
"express-useragent": "^1.0.13",
|
|
42
42
|
"extend-with-super": "^2.0.0",
|
|
43
43
|
"gitana": "^1.0.322",
|
|
44
44
|
"handlebars": "^4.4.2",
|
|
45
45
|
"hbs": "^4.0.5",
|
|
46
46
|
"helmet": "^4.6.0",
|
|
47
|
-
"http-proxy": "
|
|
47
|
+
"http-proxy": "file:./temp/http-proxy",
|
|
48
48
|
"install": "^0.13.0",
|
|
49
49
|
"ioredis": "4.28.5",
|
|
50
50
|
"json5": "^1.0.1",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"serve-favicon": "^2.5.0",
|
|
85
85
|
"session-file-store": "^0.2.2",
|
|
86
86
|
"sha1": "^1.1.1",
|
|
87
|
-
"socket.io": "^4.
|
|
87
|
+
"socket.io": "^4.5.1",
|
|
88
88
|
"ssl-root-cas": "^1.3.1",
|
|
89
89
|
"stomp-client": "^0.9.0",
|
|
90
90
|
"targz": "^1.0.1",
|
package/server/index.js
CHANGED
|
@@ -740,17 +740,13 @@ var initSession = function(initDone)
|
|
|
740
740
|
}
|
|
741
741
|
else if (process.configuration.session.type === "redis")
|
|
742
742
|
{
|
|
743
|
+
var IORedis = require("ioredis");
|
|
743
744
|
var redisOptions = redisHelper.redisOptions();
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
var RedisStore = connectRedis(session);
|
|
751
|
-
sessionConfig.store = new RedisStore({ client: redisClient });
|
|
752
|
-
initDone(null, session(sessionConfig));
|
|
753
|
-
});
|
|
745
|
+
var redisClient = new IORedis(redisOptions.url);
|
|
746
|
+
|
|
747
|
+
var RedisStore = connectRedis(session);
|
|
748
|
+
sessionConfig.store = new RedisStore({ client: redisClient });
|
|
749
|
+
initDone(null, session(sessionConfig));
|
|
754
750
|
}
|
|
755
751
|
else if (process.configuration.session.type === "memory" || !process.configuration.session.type)
|
|
756
752
|
{
|
package/server/standalone.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
package-lock.json binary
|