cloudcms-server 0.9.261 → 0.9.264
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/framework/controllers.js +4 -4
- package/launchpad/index.js +13 -0
- package/launchpad/launchers/cluster.js +23 -5
- package/launchpad/launchers/redis.js +47 -16
- package/launchpad/launchers/single.js +6 -0
- package/locks/locks.js +49 -4
- package/locks/providers/memory.js +9 -6
- package/locks/providers/redis.js +1 -1
- package/middleware/authentication/adapters/session.js +20 -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 +0 -1
- package/middleware/authorization/authorization.js +11 -8
- package/middleware/awareness/awareness.js +39 -27
- package/middleware/awareness/providers/abstract-async.js +130 -84
- package/middleware/awareness/providers/abstract.js +1 -1
- package/middleware/awareness/providers/memory.js +0 -14
- package/middleware/awareness/providers/redis.js +113 -232
- package/middleware/cloudcms/cloudcms.js +17 -15
- package/package.json +2 -2
- package/server/index.js +415 -407
- package/temp/clusterlock/index.js +3 -5
- package/temp/clusterlock/package.json +1 -1
- package/util/cloudcms.js +65 -86
- package/web/socket.io/socket.io.js +0 -4240
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
var AbstractAsyncProvider = require("./abstract-async");
|
|
2
2
|
|
|
3
|
-
//var redis = require("redis");
|
|
4
|
-
var async = require("async");
|
|
5
|
-
|
|
6
|
-
var logFactory = require("../../../util/logger");
|
|
7
|
-
//var redisHelper = require("../../../util/redis");
|
|
8
|
-
|
|
9
3
|
var redisClientFactory = require("../../../clients/redis");
|
|
10
4
|
const redisHelper = require("../../../util/redis");
|
|
11
5
|
|
|
@@ -22,7 +16,7 @@ class RedisProvider extends AbstractAsyncProvider
|
|
|
22
16
|
{
|
|
23
17
|
var self = this;
|
|
24
18
|
|
|
25
|
-
redisClientFactory.create(config, function(err, _client) {
|
|
19
|
+
redisClientFactory.create(self.config, function(err, _client) {
|
|
26
20
|
|
|
27
21
|
if (err) {
|
|
28
22
|
return callback(err);
|
|
@@ -33,69 +27,30 @@ class RedisProvider extends AbstractAsyncProvider
|
|
|
33
27
|
return callback();
|
|
34
28
|
|
|
35
29
|
});
|
|
36
|
-
|
|
37
|
-
(async function() {
|
|
38
|
-
var redisOptions = redisHelper.redisOptions(this.config, "CLOUDCMS_AWARENESS");
|
|
39
|
-
await redisHelper.createAndConnect(redisOptions, function(err, _client) {
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
})();
|
|
43
30
|
}
|
|
44
31
|
|
|
45
|
-
readOrCreateChannel(channelId, callback)
|
|
46
|
-
{
|
|
47
|
-
var self = this;
|
|
48
|
-
|
|
49
|
-
(async function() {
|
|
50
|
-
|
|
51
|
-
await self.client.get("channel-" + channelId, function(err, channelJsonText) {
|
|
52
|
-
|
|
53
|
-
if (err) {
|
|
54
|
-
return callback(err);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (channelJsonText)
|
|
58
|
-
{
|
|
59
|
-
var channel = JSON.parse("" + channelJsonText);
|
|
60
|
-
return callback(null, channel);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
(async function() {
|
|
64
|
-
var channel = {};
|
|
65
|
-
await self.client.set("channel-" + channelId, JSON.stringify(channel), function (err) {
|
|
66
|
-
|
|
67
|
-
if (err) {
|
|
68
|
-
return callback(err);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
callback(null, channel);
|
|
72
|
-
});
|
|
73
|
-
})();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
})();
|
|
77
|
-
};
|
|
78
|
-
|
|
79
32
|
readChannel(channelId, callback)
|
|
80
33
|
{
|
|
81
34
|
var self = this;
|
|
82
35
|
|
|
83
36
|
(async function() {
|
|
84
37
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
38
|
+
try
|
|
39
|
+
{
|
|
40
|
+
var channel = null;
|
|
41
|
+
|
|
42
|
+
var channelJsonText = await self.client.get("channel-" + channelId);
|
|
91
43
|
if (channelJsonText)
|
|
92
44
|
{
|
|
93
|
-
|
|
94
|
-
return callback(null, channel);
|
|
45
|
+
channel = JSON.parse("" + channelJsonText);
|
|
95
46
|
}
|
|
96
47
|
|
|
97
|
-
callback();
|
|
98
|
-
}
|
|
48
|
+
callback(null, channel);
|
|
49
|
+
}
|
|
50
|
+
catch (err)
|
|
51
|
+
{
|
|
52
|
+
return callback(err);
|
|
53
|
+
}
|
|
99
54
|
|
|
100
55
|
})();
|
|
101
56
|
};
|
|
@@ -105,15 +60,17 @@ class RedisProvider extends AbstractAsyncProvider
|
|
|
105
60
|
var self = this;
|
|
106
61
|
|
|
107
62
|
(async function() {
|
|
108
|
-
|
|
109
|
-
await self.client.set("channel-" + channelId, JSON.stringify(channel), function(err) {
|
|
110
|
-
|
|
111
|
-
if (err) {
|
|
112
|
-
return callback(err);
|
|
113
|
-
}
|
|
114
63
|
|
|
64
|
+
try
|
|
65
|
+
{
|
|
66
|
+
await self.client.set("channel-" + channelId, JSON.stringify(channel));
|
|
67
|
+
|
|
115
68
|
callback();
|
|
116
|
-
}
|
|
69
|
+
}
|
|
70
|
+
catch (err)
|
|
71
|
+
{
|
|
72
|
+
return callback(err);
|
|
73
|
+
}
|
|
117
74
|
|
|
118
75
|
})();
|
|
119
76
|
};
|
|
@@ -124,14 +81,9 @@ class RedisProvider extends AbstractAsyncProvider
|
|
|
124
81
|
|
|
125
82
|
(async function() {
|
|
126
83
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (err)
|
|
131
|
-
{
|
|
132
|
-
return callback(err);
|
|
133
|
-
}
|
|
134
|
-
|
|
84
|
+
try
|
|
85
|
+
{
|
|
86
|
+
var channelKeys = await self.client.keys("channel-*");
|
|
135
87
|
if (!channelKeys || channelKeys.length === 0)
|
|
136
88
|
{
|
|
137
89
|
return callback(null, []);
|
|
@@ -145,97 +97,13 @@ class RedisProvider extends AbstractAsyncProvider
|
|
|
145
97
|
}
|
|
146
98
|
|
|
147
99
|
callback(null, channelIds);
|
|
148
|
-
});
|
|
149
|
-
})();
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* @override
|
|
154
|
-
*/
|
|
155
|
-
expire(beforeMs, callback)
|
|
156
|
-
{
|
|
157
|
-
var self = this;
|
|
158
|
-
|
|
159
|
-
self.listChannelIds(function(err, channelIds) {
|
|
160
|
-
|
|
161
|
-
if (err) {
|
|
162
|
-
return callback(err);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (!channelIds || channelIds.length === 0) {
|
|
166
|
-
return callback(null, [], {});
|
|
167
100
|
}
|
|
168
|
-
|
|
169
|
-
// a list of channel IDs whose memberships were updated
|
|
170
|
-
var updatedMembershipChannelIds = [];
|
|
171
|
-
var expiredUserIdsByChannelId = {};
|
|
172
|
-
|
|
173
|
-
var fns = [];
|
|
174
|
-
|
|
175
|
-
for (var i = 0; i < channelIds.length; i++)
|
|
101
|
+
catch (err)
|
|
176
102
|
{
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
var fn = function (channelId, updatedMembershipChannelIds, expiredUserIdsByChannelId, beforeMs) {
|
|
180
|
-
return function (done) {
|
|
181
|
-
|
|
182
|
-
self.readChannel(channelId, function(err, channel) {
|
|
183
|
-
|
|
184
|
-
if (err) {
|
|
185
|
-
return done(err);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (!channel) {
|
|
189
|
-
return done();
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (channel.users)
|
|
193
|
-
{
|
|
194
|
-
// populate all of the user IDs that need to be removed
|
|
195
|
-
var userIdsToRemove = [];
|
|
196
|
-
for (var userId in channel.users)
|
|
197
|
-
{
|
|
198
|
-
var entry = channel.users[userId];
|
|
199
|
-
if (entry.time < beforeMs)
|
|
200
|
-
{
|
|
201
|
-
updatedMembershipChannelIds.push(channelId);
|
|
202
|
-
userIdsToRemove.push(userId);
|
|
203
|
-
|
|
204
|
-
var expiredUserIds = expiredUserIdsByChannelId[channelId]
|
|
205
|
-
if (!expiredUserIds) {
|
|
206
|
-
expiredUserIds = expiredUserIdsByChannelId[channelId] = [];
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
expiredUserIds.push(userId);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// remove the user IDs
|
|
214
|
-
for (var i = 0; i < userIdsToRemove.length; i++)
|
|
215
|
-
{
|
|
216
|
-
delete channel.users[userIdsToRemove[i]];
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
self.writeChannel(channelId, channel, function() {
|
|
220
|
-
done();
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
});
|
|
225
|
-
};
|
|
226
|
-
}(channelId, updatedMembershipChannelIds, expiredUserIdsByChannelId, beforeMs);
|
|
227
|
-
fns.push(fn);
|
|
103
|
+
callback(err);
|
|
228
104
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if (err) {
|
|
233
|
-
return callback(err);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
callback(null, updatedMembershipChannelIds, expiredUserIdsByChannelId);
|
|
237
|
-
});
|
|
238
|
-
});
|
|
105
|
+
|
|
106
|
+
})();
|
|
239
107
|
};
|
|
240
108
|
|
|
241
109
|
readLock(lockId, callback)
|
|
@@ -244,37 +112,42 @@ class RedisProvider extends AbstractAsyncProvider
|
|
|
244
112
|
|
|
245
113
|
(async function() {
|
|
246
114
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
115
|
+
try
|
|
116
|
+
{
|
|
117
|
+
var lock = null;
|
|
118
|
+
|
|
119
|
+
var lockJsonText = await self.client.get("lock-" + lockId);
|
|
253
120
|
if (lockJsonText)
|
|
254
121
|
{
|
|
255
|
-
|
|
256
|
-
return callback(null, lock);
|
|
122
|
+
lock = JSON.parse("" + lockJsonText);
|
|
257
123
|
}
|
|
258
124
|
|
|
259
|
-
callback();
|
|
260
|
-
}
|
|
125
|
+
callback(null, lock);
|
|
126
|
+
}
|
|
127
|
+
catch (err)
|
|
128
|
+
{
|
|
129
|
+
callback(err);
|
|
130
|
+
}
|
|
131
|
+
|
|
261
132
|
})();
|
|
262
133
|
};
|
|
263
134
|
|
|
264
135
|
writeLock(lockId, lock, callback)
|
|
265
136
|
{
|
|
266
137
|
var self = this;
|
|
267
|
-
|
|
138
|
+
|
|
268
139
|
(async function() {
|
|
269
|
-
|
|
270
|
-
await self.client.set("lock-" + lockId, JSON.stringify(lock), function(err) {
|
|
271
|
-
|
|
272
|
-
if (err) {
|
|
273
|
-
return callback(err);
|
|
274
|
-
}
|
|
275
140
|
|
|
141
|
+
try
|
|
142
|
+
{
|
|
143
|
+
await self.client.set("lock-" + lockId, JSON.stringify(lock));
|
|
144
|
+
|
|
276
145
|
callback();
|
|
277
|
-
}
|
|
146
|
+
}
|
|
147
|
+
catch (err)
|
|
148
|
+
{
|
|
149
|
+
callback(err);
|
|
150
|
+
}
|
|
278
151
|
|
|
279
152
|
})();
|
|
280
153
|
};
|
|
@@ -284,15 +157,17 @@ class RedisProvider extends AbstractAsyncProvider
|
|
|
284
157
|
var self = this;
|
|
285
158
|
|
|
286
159
|
(async function() {
|
|
287
|
-
|
|
288
|
-
await self.client.del("lock-" + lockId, function(err) {
|
|
289
|
-
|
|
290
|
-
if (err) {
|
|
291
|
-
return callback(err);
|
|
292
|
-
}
|
|
293
160
|
|
|
161
|
+
try
|
|
162
|
+
{
|
|
163
|
+
await self.client.del("lock-" + lockId);
|
|
164
|
+
|
|
294
165
|
callback();
|
|
295
|
-
}
|
|
166
|
+
}
|
|
167
|
+
catch (err)
|
|
168
|
+
{
|
|
169
|
+
callback(err);
|
|
170
|
+
}
|
|
296
171
|
|
|
297
172
|
})();
|
|
298
173
|
};
|
|
@@ -302,15 +177,10 @@ class RedisProvider extends AbstractAsyncProvider
|
|
|
302
177
|
var self = this;
|
|
303
178
|
|
|
304
179
|
(async function() {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (err)
|
|
310
|
-
{
|
|
311
|
-
return callback(err);
|
|
312
|
-
}
|
|
313
|
-
|
|
180
|
+
|
|
181
|
+
try
|
|
182
|
+
{
|
|
183
|
+
var lockKeys = await self.client.keys("lock-*");
|
|
314
184
|
if (!lockKeys || lockKeys.length === 0)
|
|
315
185
|
{
|
|
316
186
|
return callback(null, []);
|
|
@@ -324,7 +194,11 @@ class RedisProvider extends AbstractAsyncProvider
|
|
|
324
194
|
}
|
|
325
195
|
|
|
326
196
|
callback(null, lockIds);
|
|
327
|
-
}
|
|
197
|
+
}
|
|
198
|
+
catch (err)
|
|
199
|
+
{
|
|
200
|
+
callback(err);
|
|
201
|
+
}
|
|
328
202
|
|
|
329
203
|
})();
|
|
330
204
|
};
|
|
@@ -335,69 +209,76 @@ class RedisProvider extends AbstractAsyncProvider
|
|
|
335
209
|
|
|
336
210
|
(async function() {
|
|
337
211
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
212
|
+
var session = null;
|
|
213
|
+
|
|
214
|
+
try
|
|
215
|
+
{
|
|
216
|
+
var sessionJsonText = await self.client.get("session-" + sessionId);
|
|
344
217
|
if (sessionJsonText)
|
|
345
218
|
{
|
|
346
|
-
|
|
219
|
+
session = JSON.parse("" + sessionJsonText);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (session)
|
|
223
|
+
{
|
|
347
224
|
return callback(null, session);
|
|
348
225
|
}
|
|
349
226
|
|
|
350
227
|
// create a new session
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
})();
|
|
362
|
-
});
|
|
228
|
+
session = {};
|
|
229
|
+
await self.client.set("session-" + sessionId, JSON.stringify(session));
|
|
230
|
+
|
|
231
|
+
callback(null, session);
|
|
232
|
+
}
|
|
233
|
+
catch (err)
|
|
234
|
+
{
|
|
235
|
+
callback(err);
|
|
236
|
+
}
|
|
237
|
+
|
|
363
238
|
})();
|
|
364
239
|
}
|
|
365
240
|
|
|
366
241
|
updateSession(sessionId, session, callback)
|
|
367
242
|
{
|
|
368
243
|
var self = this;
|
|
369
|
-
|
|
244
|
+
|
|
370
245
|
if (!session) {
|
|
371
246
|
session = {};
|
|
372
247
|
}
|
|
373
248
|
|
|
374
249
|
(async function() {
|
|
375
250
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
return callback(err);
|
|
381
|
-
}
|
|
382
|
-
|
|
251
|
+
try
|
|
252
|
+
{
|
|
253
|
+
await self.client.set("session-" + sessionId, JSON.stringify(session));
|
|
254
|
+
|
|
383
255
|
callback(null, session);
|
|
384
|
-
}
|
|
256
|
+
}
|
|
257
|
+
catch (err)
|
|
258
|
+
{
|
|
259
|
+
callback(err);
|
|
260
|
+
}
|
|
261
|
+
|
|
385
262
|
})();
|
|
386
263
|
}
|
|
387
264
|
|
|
388
265
|
deleteSession(sessionId, callback)
|
|
389
266
|
{
|
|
390
267
|
var self = this;
|
|
391
|
-
|
|
392
|
-
(async function() {
|
|
393
|
-
await self.client.del("session-" + sessionId, function (err) {
|
|
394
|
-
|
|
395
|
-
if (err) {
|
|
396
|
-
return callback(err);
|
|
397
|
-
}
|
|
398
268
|
|
|
269
|
+
(async function() {
|
|
270
|
+
|
|
271
|
+
try
|
|
272
|
+
{
|
|
273
|
+
await self.client.del("session-" + sessionId);
|
|
274
|
+
|
|
399
275
|
callback();
|
|
400
|
-
}
|
|
276
|
+
}
|
|
277
|
+
catch (err)
|
|
278
|
+
{
|
|
279
|
+
callback(err);
|
|
280
|
+
}
|
|
281
|
+
|
|
401
282
|
})();
|
|
402
283
|
}
|
|
403
284
|
|
|
@@ -441,7 +441,13 @@ exports = module.exports = function()
|
|
|
441
441
|
if (err) {
|
|
442
442
|
return callback(err);
|
|
443
443
|
}
|
|
444
|
-
|
|
444
|
+
|
|
445
|
+
var branch = CACHED_BRANCHES[cacheKey];
|
|
446
|
+
if (branch) {
|
|
447
|
+
callback(null, Chain(branch));
|
|
448
|
+
return releaseLockFn();
|
|
449
|
+
}
|
|
450
|
+
|
|
445
451
|
var loadFn = function(finished) {
|
|
446
452
|
|
|
447
453
|
Chain(repository).trap(function(e) {
|
|
@@ -468,23 +474,21 @@ exports = module.exports = function()
|
|
|
468
474
|
|
|
469
475
|
if (err) {
|
|
470
476
|
|
|
477
|
+
callback(err);
|
|
478
|
+
|
|
471
479
|
// release the lock
|
|
472
|
-
releaseLockFn();
|
|
473
|
-
|
|
474
|
-
// do the callback
|
|
475
|
-
return callback(err);
|
|
480
|
+
return releaseLockFn();
|
|
476
481
|
}
|
|
477
482
|
|
|
478
483
|
// success!
|
|
479
484
|
|
|
480
485
|
// store in cache
|
|
481
486
|
CACHED_BRANCHES[cacheKey] = branch;
|
|
482
|
-
|
|
487
|
+
|
|
488
|
+
callback(null, branch);
|
|
489
|
+
|
|
483
490
|
// release the lock
|
|
484
|
-
releaseLockFn();
|
|
485
|
-
|
|
486
|
-
// do the callback
|
|
487
|
-
return callback(null, branch);
|
|
491
|
+
return releaseLockFn();
|
|
488
492
|
});
|
|
489
493
|
}
|
|
490
494
|
|
|
@@ -1443,11 +1447,10 @@ exports = module.exports = function()
|
|
|
1443
1447
|
|
|
1444
1448
|
// the range requested (for streaming)
|
|
1445
1449
|
//var range = req.headers["range"];
|
|
1446
|
-
|
|
1450
|
+
|
|
1447
1451
|
cloudcmsUtil.preview(contentStore, gitana, repositoryId, branchId, nodeId, nodePath, attachmentId, locale, previewId, size, mimetype, forceReload, function(err, filePath, cacheInfo, releaseLock) {
|
|
1448
1452
|
|
|
1449
|
-
if (err)
|
|
1450
|
-
{
|
|
1453
|
+
if (err) {
|
|
1451
1454
|
req.log("Error on preview node: " + err.message + ", err: " + JSON.stringify(err));
|
|
1452
1455
|
}
|
|
1453
1456
|
|
|
@@ -1479,8 +1482,7 @@ exports = module.exports = function()
|
|
|
1479
1482
|
// UZI: file deleted by invalidate before this gets called
|
|
1480
1483
|
contentStore.sendFile(res, filePath, cacheInfo, function(err) {
|
|
1481
1484
|
|
|
1482
|
-
if (err)
|
|
1483
|
-
{
|
|
1485
|
+
if (err) {
|
|
1484
1486
|
util.handleSendFileError(req, res, filePath, cacheInfo, req.log, err);
|
|
1485
1487
|
}
|
|
1486
1488
|
|
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.264",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "git://github.com/gitana/cloudcms-server.git"
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"alpaca": "^1.5.27",
|
|
21
21
|
"archiver": "^1.3.0",
|
|
22
22
|
"async": "^3.2.3",
|
|
23
|
+
"async-lock": "^1.3.2",
|
|
23
24
|
"aws-sdk": "^2.544.0",
|
|
24
25
|
"basic-auth": "^1.1.0",
|
|
25
26
|
"body-parser": "^1.19.0",
|
|
@@ -79,7 +80,6 @@
|
|
|
79
80
|
"request": "^2.88.0",
|
|
80
81
|
"request-param": "^1.0.1",
|
|
81
82
|
"response-time": "^2.3.2",
|
|
82
|
-
"rwlock": "^5.0.0",
|
|
83
83
|
"semver": "^5.7.1",
|
|
84
84
|
"serve-favicon": "^2.5.0",
|
|
85
85
|
"session-file-store": "^0.2.2",
|