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
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
var redis = require("redis");
|
|
4
|
-
var logFactory = require("../../../util/logger");
|
|
1
|
+
var redisClientFactory = require("../../../clients/redis");
|
|
2
|
+
const redisHelper = require("../../../util/redis");
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* Redis distributed cache.
|
|
@@ -11,123 +9,163 @@ var logFactory = require("../../../util/logger");
|
|
|
11
9
|
exports = module.exports = function(cacheConfig)
|
|
12
10
|
{
|
|
13
11
|
var client = null;
|
|
14
|
-
|
|
15
|
-
var logger =
|
|
16
|
-
logger.setLevel("error");
|
|
17
|
-
|
|
18
|
-
// allow for global redis default
|
|
19
|
-
// allow for redis broadcast specific
|
|
20
|
-
// otherwise default to error
|
|
21
|
-
if (typeof(process.env.CLOUDCMS_REDIS_DEBUG_LEVEL) !== "undefined") {
|
|
22
|
-
logger.setLevel(("" + process.env.CLOUDCMS_REDIS_DEBUG_LEVEL).toLowerCase(), true);
|
|
23
|
-
}
|
|
24
|
-
else if (typeof(process.env.CLOUDCMS_CACHE_REDIS_DEBUG_LEVEL) !== "undefined") {
|
|
25
|
-
logger.setLevel(("" + process.env.CLOUDCMS_CACHE_REDIS_DEBUG_LEVEL).toLowerCase(), true);
|
|
26
|
-
}
|
|
12
|
+
|
|
13
|
+
var logger = redisHelper.redisLogger("REDIS_CACHE", "CLOUDCMS_CACHE_", "error")
|
|
27
14
|
|
|
28
15
|
var r = {};
|
|
29
16
|
|
|
30
17
|
r.init = function(callback)
|
|
31
18
|
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
|
|
44
|
-
{
|
|
45
|
-
redisEndpoint = process.env.CLOUDCMS_CACHE_REDIS_ENDPOINT;
|
|
46
|
-
}
|
|
47
|
-
if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
|
|
48
|
-
{
|
|
49
|
-
redisEndpoint = process.env.CLOUDCMS_REDIS_ENDPOINT;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
var redisOptions = {};
|
|
53
|
-
|
|
54
|
-
//redis.debug_mode = true;
|
|
55
|
-
|
|
56
|
-
client = redis.createClient(redisPort, redisEndpoint, redisOptions);
|
|
57
|
-
|
|
58
|
-
callback();
|
|
19
|
+
redisClientFactory.create(cacheConfig, function(err, _client) {
|
|
20
|
+
|
|
21
|
+
if (err) {
|
|
22
|
+
return callback(err);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
client = _client;
|
|
26
|
+
|
|
27
|
+
return callback();
|
|
28
|
+
|
|
29
|
+
});
|
|
59
30
|
};
|
|
60
31
|
|
|
61
32
|
r.write = function(key, value, seconds, callback)
|
|
62
33
|
{
|
|
63
|
-
|
|
64
|
-
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
34
|
+
logger.info('write, key = ' + key + ', value = ' + value + ', seconds = ' + seconds + ', typeofval: ' + typeof(value));
|
|
35
|
+
(async function() {
|
|
36
|
+
|
|
37
|
+
var reply = null;
|
|
38
|
+
var err = null;
|
|
39
|
+
|
|
40
|
+
try
|
|
41
|
+
{
|
|
42
|
+
var config = {};
|
|
43
|
+
if (seconds >= 0) {
|
|
44
|
+
config["EX"] = seconds;
|
|
68
45
|
}
|
|
46
|
+
|
|
47
|
+
reply = await client.set(key, JSON.stringify(value), config);
|
|
48
|
+
}
|
|
49
|
+
catch (e)
|
|
50
|
+
{
|
|
51
|
+
err = e;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (reply) {
|
|
69
55
|
logger.info("write -> reply = " + reply);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
logger.info("write.ex -> reply = " + reply);
|
|
80
|
-
callback(err, reply);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (err) {
|
|
59
|
+
logger.error("write error. key: " + key + " value: " + JSON.stringify(value) + ". error:" + err + ", value type: " + typeof(value));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
callback(err, reply);
|
|
63
|
+
|
|
64
|
+
})();
|
|
83
65
|
};
|
|
84
66
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
67
|
+
r.read = function(key, callback)
|
|
68
|
+
{
|
|
69
|
+
logger.info('read, key = ' + key);
|
|
88
70
|
|
|
71
|
+
(async function() {
|
|
72
|
+
|
|
73
|
+
var err = null;
|
|
74
|
+
var reply = null;
|
|
75
|
+
|
|
76
|
+
try
|
|
77
|
+
{
|
|
78
|
+
reply = await client.get(key);
|
|
79
|
+
}
|
|
80
|
+
catch (e)
|
|
81
|
+
{
|
|
82
|
+
err = e;
|
|
83
|
+
}
|
|
84
|
+
|
|
89
85
|
if (err) {
|
|
90
|
-
logger.error("read error. key: " + key + ". error:" + err);
|
|
86
|
+
logger.error("read error. key: " + key + ". error: " + err);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (reply) {
|
|
90
|
+
logger.info("read. key: " + key + " -> reply = " + reply);
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
|
|
94
93
|
var result = null;
|
|
95
|
-
|
|
94
|
+
try
|
|
96
95
|
{
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
result = JSON.parse(reply);
|
|
97
|
+
}
|
|
99
98
|
catch (ex)
|
|
100
99
|
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
result = null;
|
|
101
|
+
err = ex;
|
|
102
|
+
|
|
103
|
+
if (err)
|
|
104
|
+
{
|
|
104
105
|
logger.error("error parsing reply. key: " + key + ". error:" + err);
|
|
105
106
|
}
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
}
|
|
108
|
+
|
|
108
109
|
callback(err, result);
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
})();
|
|
111
|
+
};
|
|
111
112
|
|
|
112
113
|
r.remove = function(key, callback)
|
|
113
114
|
{
|
|
114
|
-
logger.info(
|
|
115
|
-
|
|
115
|
+
logger.info('remove, key = ' + key);
|
|
116
|
+
|
|
117
|
+
(async function() {
|
|
118
|
+
|
|
119
|
+
var err = null;
|
|
120
|
+
|
|
121
|
+
try
|
|
122
|
+
{
|
|
123
|
+
await client.del(key);
|
|
124
|
+
logger.info("remove. key: " + key);
|
|
125
|
+
}
|
|
126
|
+
catch (e)
|
|
127
|
+
{
|
|
128
|
+
err = e;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (err) {
|
|
132
|
+
logger.error("del error. key: " + key + ". error: " + err);
|
|
133
|
+
}
|
|
134
|
+
|
|
116
135
|
callback(err);
|
|
117
|
-
});
|
|
136
|
+
})();
|
|
118
137
|
};
|
|
119
138
|
|
|
120
139
|
r.keys = function(prefix, callback)
|
|
121
|
-
|
|
122
|
-
logger.info('keys
|
|
123
|
-
|
|
140
|
+
{
|
|
141
|
+
logger.info('keys, prefix = ' + prefix);
|
|
142
|
+
|
|
143
|
+
(async function() {
|
|
144
|
+
|
|
145
|
+
var err = null;
|
|
146
|
+
var reply = null;
|
|
147
|
+
|
|
148
|
+
try
|
|
149
|
+
{
|
|
150
|
+
reply = await client.keys(prefix + '*');
|
|
151
|
+
}
|
|
152
|
+
catch (e)
|
|
153
|
+
{
|
|
154
|
+
err = e;
|
|
155
|
+
}
|
|
156
|
+
|
|
124
157
|
if (err) {
|
|
125
|
-
logger.error("error reading prefix: " + prefix + ". error:" + err);
|
|
158
|
+
logger.error("error reading keys for prefix: " + prefix + ". error:" + err);
|
|
126
159
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
160
|
+
|
|
161
|
+
if (reply) {
|
|
162
|
+
logger.info("keys -> reply = " + reply);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
callback(err, reply);
|
|
166
|
+
|
|
167
|
+
})();
|
|
168
|
+
};
|
|
131
169
|
|
|
132
170
|
return r;
|
|
133
171
|
};
|
|
@@ -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
|
|
@@ -436,8 +436,18 @@ exports = module.exports = function()
|
|
|
436
436
|
}
|
|
437
437
|
|
|
438
438
|
// only allow one "thread" at a time to load the branch
|
|
439
|
-
_LOCK(cacheKey, function(releaseLockFn) {
|
|
440
|
-
|
|
439
|
+
_LOCK(cacheKey, function(err, releaseLockFn) {
|
|
440
|
+
|
|
441
|
+
if (err) {
|
|
442
|
+
return callback(err);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
var branch = CACHED_BRANCHES[cacheKey];
|
|
446
|
+
if (branch) {
|
|
447
|
+
callback(null, Chain(branch));
|
|
448
|
+
return releaseLockFn();
|
|
449
|
+
}
|
|
450
|
+
|
|
441
451
|
var loadFn = function(finished) {
|
|
442
452
|
|
|
443
453
|
Chain(repository).trap(function(e) {
|
|
@@ -464,23 +474,21 @@ exports = module.exports = function()
|
|
|
464
474
|
|
|
465
475
|
if (err) {
|
|
466
476
|
|
|
477
|
+
callback(err);
|
|
478
|
+
|
|
467
479
|
// release the lock
|
|
468
|
-
releaseLockFn();
|
|
469
|
-
|
|
470
|
-
// do the callback
|
|
471
|
-
return callback(err);
|
|
480
|
+
return releaseLockFn();
|
|
472
481
|
}
|
|
473
482
|
|
|
474
483
|
// success!
|
|
475
484
|
|
|
476
485
|
// store in cache
|
|
477
486
|
CACHED_BRANCHES[cacheKey] = branch;
|
|
478
|
-
|
|
487
|
+
|
|
488
|
+
callback(null, branch);
|
|
489
|
+
|
|
479
490
|
// release the lock
|
|
480
|
-
releaseLockFn();
|
|
481
|
-
|
|
482
|
-
// do the callback
|
|
483
|
-
return callback(null, branch);
|
|
491
|
+
return releaseLockFn();
|
|
484
492
|
});
|
|
485
493
|
}
|
|
486
494
|
|
|
@@ -1439,11 +1447,10 @@ exports = module.exports = function()
|
|
|
1439
1447
|
|
|
1440
1448
|
// the range requested (for streaming)
|
|
1441
1449
|
//var range = req.headers["range"];
|
|
1442
|
-
|
|
1450
|
+
|
|
1443
1451
|
cloudcmsUtil.preview(contentStore, gitana, repositoryId, branchId, nodeId, nodePath, attachmentId, locale, previewId, size, mimetype, forceReload, function(err, filePath, cacheInfo, releaseLock) {
|
|
1444
1452
|
|
|
1445
|
-
if (err)
|
|
1446
|
-
{
|
|
1453
|
+
if (err) {
|
|
1447
1454
|
req.log("Error on preview node: " + err.message + ", err: " + JSON.stringify(err));
|
|
1448
1455
|
}
|
|
1449
1456
|
|
|
@@ -1475,8 +1482,7 @@ exports = module.exports = function()
|
|
|
1475
1482
|
// UZI: file deleted by invalidate before this gets called
|
|
1476
1483
|
contentStore.sendFile(res, filePath, cacheInfo, function(err) {
|
|
1477
1484
|
|
|
1478
|
-
if (err)
|
|
1479
|
-
{
|
|
1485
|
+
if (err) {
|
|
1480
1486
|
util.handleSendFileError(req, res, filePath, cacheInfo, req.log, err);
|
|
1481
1487
|
}
|
|
1482
1488
|
|
package/middleware/form/form.js
CHANGED
|
@@ -120,7 +120,7 @@ exports = module.exports = function()
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
// post form to Cloud CMS using public method
|
|
123
|
-
var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + url;
|
|
123
|
+
var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + url;
|
|
124
124
|
|
|
125
125
|
var headers = {};
|
|
126
126
|
headers["Authorization"] = req.gitana.platform().getDriver().getHttpHeaders()["Authorization"];
|
|
@@ -183,8 +183,8 @@ exports = module.exports = function()
|
|
|
183
183
|
req.branch(function(err, branch) {
|
|
184
184
|
|
|
185
185
|
var url = branch.getUri() + "/alpaca/datasource";
|
|
186
|
-
|
|
187
|
-
var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + url;
|
|
186
|
+
|
|
187
|
+
var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + url;
|
|
188
188
|
|
|
189
189
|
var headers = {};
|
|
190
190
|
headers["Authorization"] = req.gitana.platform().getDriver().getHttpHeaders()["Authorization"];
|
|
@@ -39,6 +39,13 @@ exports = module.exports = function()
|
|
|
39
39
|
|
|
40
40
|
var doDeploy = function(host, moduleId, moduleConfig, callback)
|
|
41
41
|
{
|
|
42
|
+
// broadcast: module_before_deploy
|
|
43
|
+
process.broadcast.publish("module_before_deploy", {
|
|
44
|
+
"host": host,
|
|
45
|
+
"moduleId": moduleId,
|
|
46
|
+
"moduleConfig": moduleConfig
|
|
47
|
+
});
|
|
48
|
+
|
|
42
49
|
logFn("Start doDeploy, host: " + host + ", module ID: " + moduleId + ", module config: " + JSON.stringify(moduleConfig, null, 2));;
|
|
43
50
|
|
|
44
51
|
if (!moduleConfig)
|
|
@@ -94,16 +101,26 @@ exports = module.exports = function()
|
|
|
94
101
|
|
|
95
102
|
var targetStore = stores["modules"];
|
|
96
103
|
var targetOffsetPath = moduleId;
|
|
97
|
-
|
|
104
|
+
|
|
105
|
+
//logFn("From: " + sourceType + ", " + sourceUrl + ", " + sourcePath + ", " + sourceBranch);
|
|
106
|
+
//logFn("To: " + targetStore + ", path: " + targetOffsetPath);
|
|
107
|
+
|
|
98
108
|
util.gitCheckout(host, sourceType, sourceUrl, sourcePath, sourceBranch, targetStore, targetOffsetPath, false, logFn, function (err) {
|
|
99
109
|
|
|
100
|
-
|
|
110
|
+
logFn("After util.gitCheckout: " + JSON.stringify(err));
|
|
101
111
|
|
|
102
112
|
// invalidate any caching within the stores layer
|
|
103
113
|
storeService.invalidate(host);
|
|
104
114
|
|
|
105
|
-
|
|
106
|
-
|
|
115
|
+
logFn("After store.invalidate");
|
|
116
|
+
|
|
117
|
+
// broadcast: module_after_deploy
|
|
118
|
+
process.broadcast.publish("module_after_deploy", {
|
|
119
|
+
"host": host,
|
|
120
|
+
"moduleId": moduleId,
|
|
121
|
+
"moduleConfig": moduleConfig
|
|
122
|
+
});
|
|
123
|
+
|
|
107
124
|
callback(err);
|
|
108
125
|
});
|
|
109
126
|
});
|
|
@@ -116,10 +133,17 @@ exports = module.exports = function()
|
|
|
116
133
|
|
|
117
134
|
var doUndeploy = function(host, moduleId, moduleConfig, cacheOnly, callback)
|
|
118
135
|
{
|
|
136
|
+
// broadcast: module_before_undeploy
|
|
137
|
+
process.broadcast.publish("module_before_undeploy", {
|
|
138
|
+
"host": host,
|
|
139
|
+
"moduleId": moduleId,
|
|
140
|
+
"moduleConfig": moduleConfig
|
|
141
|
+
});
|
|
142
|
+
|
|
119
143
|
var logFn = function(text) {
|
|
120
144
|
console.log(text);
|
|
121
145
|
};
|
|
122
|
-
|
|
146
|
+
|
|
123
147
|
logFn("Start doUndeploy, host: " + host + ", module ID: " + moduleId + ", module config: " + JSON.stringify(moduleConfig, null, 2));;
|
|
124
148
|
|
|
125
149
|
storeService.produce(host, function(err, stores) {
|
|
@@ -156,12 +180,19 @@ exports = module.exports = function()
|
|
|
156
180
|
var doRefresh = function(host, moduleId, moduleConfig, callback)
|
|
157
181
|
{
|
|
158
182
|
//logFn("Start doRefresh, host: " + host + ", module ID: " + moduleId + ", module config: " + JSON.stringify(moduleConfig, null, 2));;
|
|
159
|
-
|
|
183
|
+
|
|
184
|
+
// broadcast: module_before_refresh
|
|
185
|
+
process.broadcast.publish("module_before_refresh", {
|
|
186
|
+
"host": host,
|
|
187
|
+
"moduleId": moduleId,
|
|
188
|
+
"moduleConfig": moduleConfig
|
|
189
|
+
});
|
|
190
|
+
|
|
160
191
|
storeService.produce(host, function(err, stores) {
|
|
161
192
|
|
|
162
193
|
var options = {};
|
|
163
194
|
options.host = host;
|
|
164
|
-
|
|
195
|
+
|
|
165
196
|
var modulesStore = stores.modules;
|
|
166
197
|
modulesStore.refresh(options, function(err) {
|
|
167
198
|
|
|
@@ -169,7 +200,20 @@ exports = module.exports = function()
|
|
|
169
200
|
return callback(err);
|
|
170
201
|
}
|
|
171
202
|
|
|
172
|
-
doInvalidate(host, moduleId, moduleConfig,
|
|
203
|
+
doInvalidate(host, moduleId, moduleConfig, function(err) {
|
|
204
|
+
|
|
205
|
+
if (!err)
|
|
206
|
+
{
|
|
207
|
+
// broadcast: module_after_refresh
|
|
208
|
+
process.broadcast.publish("module_after_refresh", {
|
|
209
|
+
"host": host,
|
|
210
|
+
"moduleId": moduleId,
|
|
211
|
+
"moduleConfig": moduleConfig
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
callback(err);
|
|
216
|
+
});
|
|
173
217
|
});
|
|
174
218
|
});
|
|
175
219
|
};
|
|
@@ -210,7 +254,7 @@ exports = module.exports = function()
|
|
|
210
254
|
var moduleId = message.moduleId;
|
|
211
255
|
var moduleConfig = message.moduleConfig;
|
|
212
256
|
var messageId = message.id;
|
|
213
|
-
|
|
257
|
+
|
|
214
258
|
var identifier = acquireMessageConcurrencyLockIdentifier(messageId);
|
|
215
259
|
util.executeFunction(identifier, function(exclusiveFirst, doneFn) {
|
|
216
260
|
|
|
@@ -236,6 +280,7 @@ exports = module.exports = function()
|
|
|
236
280
|
|
|
237
281
|
// invalidate this server
|
|
238
282
|
doInvalidate(host, moduleId, moduleConfig, function() {
|
|
283
|
+
|
|
239
284
|
finished(err);
|
|
240
285
|
});
|
|
241
286
|
|
|
@@ -255,7 +300,7 @@ exports = module.exports = function()
|
|
|
255
300
|
var moduleId = message.moduleId;
|
|
256
301
|
var moduleConfig = message.moduleConfig;
|
|
257
302
|
var messageId = message.id;
|
|
258
|
-
|
|
303
|
+
|
|
259
304
|
var identifier = acquireMessageConcurrencyLockIdentifier(messageId);
|
|
260
305
|
util.executeFunction(identifier, function(exclusiveFirst, doneFn) {
|
|
261
306
|
|
|
@@ -278,6 +323,14 @@ exports = module.exports = function()
|
|
|
278
323
|
|
|
279
324
|
// invalidate this server
|
|
280
325
|
doInvalidate(host, moduleId, moduleConfig, function() {
|
|
326
|
+
|
|
327
|
+
// broadcast: module_after_undeploy
|
|
328
|
+
process.broadcast.publish("module_after_undeploy", {
|
|
329
|
+
"host": host,
|
|
330
|
+
"moduleId": moduleId,
|
|
331
|
+
"moduleConfig": moduleConfig
|
|
332
|
+
});
|
|
333
|
+
|
|
281
334
|
finished(err);
|
|
282
335
|
});
|
|
283
336
|
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
var path = require('path');
|
|
2
|
-
// var fs = require('fs');
|
|
3
|
-
// var http = require('http');
|
|
4
|
-
// var https = require('https');
|
|
5
|
-
|
|
6
|
-
// var httpProxy = require('http-proxy');
|
|
7
|
-
|
|
8
|
-
// var oauth2 = require("../../util/oauth2")();
|
|
9
|
-
|
|
10
|
-
// var async = require("async");
|
|
11
2
|
|
|
12
3
|
var util = require("../../util/util");
|
|
13
|
-
// var auth = require("../../util/auth");
|
|
14
4
|
|
|
15
5
|
var proxyFactory = require("../../util/proxy-factory");
|
|
16
6
|
|
|
@@ -82,20 +72,17 @@ exports = module.exports = function()
|
|
|
82
72
|
contentStore.existsFile(filePath, function(exists) {
|
|
83
73
|
|
|
84
74
|
if (!exists) {
|
|
85
|
-
callback();
|
|
86
|
-
return;
|
|
75
|
+
return callback();
|
|
87
76
|
}
|
|
88
77
|
|
|
89
78
|
contentStore.fileStats(filePath, function(err, stats) {
|
|
90
79
|
|
|
91
80
|
if (err) {
|
|
92
|
-
callback();
|
|
93
|
-
return;
|
|
81
|
+
return callback();
|
|
94
82
|
}
|
|
95
83
|
|
|
96
|
-
if (stats.size
|
|
97
|
-
callback();
|
|
98
|
-
return;
|
|
84
|
+
if (stats.size === 0) {
|
|
85
|
+
return callback();
|
|
99
86
|
}
|
|
100
87
|
|
|
101
88
|
var handleGoodStream = function()
|
|
@@ -117,8 +104,7 @@ exports = module.exports = function()
|
|
|
117
104
|
// check cacheInfo for expireTime
|
|
118
105
|
contentStore.readFile(filePath + ".cache", function(err, cacheInfoText) {
|
|
119
106
|
|
|
120
|
-
if (err || !cacheInfoText)
|
|
121
|
-
{
|
|
107
|
+
if (err || !cacheInfoText) {
|
|
122
108
|
return handleBadStream();
|
|
123
109
|
}
|
|
124
110
|
|
|
@@ -215,7 +201,7 @@ exports = module.exports = function()
|
|
|
215
201
|
contentStore.writeFile(filePath + ".cache", JSON.stringify(cacheInfo), function() {
|
|
216
202
|
_end.call(res, data, encoding);
|
|
217
203
|
});
|
|
218
|
-
|
|
204
|
+
};
|
|
219
205
|
|
|
220
206
|
callback();
|
|
221
207
|
});
|
|
@@ -237,7 +223,7 @@ exports = module.exports = function()
|
|
|
237
223
|
{
|
|
238
224
|
req.url = "/";
|
|
239
225
|
}
|
|
240
|
-
|
|
226
|
+
|
|
241
227
|
// caching scenario
|
|
242
228
|
_handleCacheRead(req, function (err, readStream) {
|
|
243
229
|
|
|
@@ -257,6 +243,7 @@ exports = module.exports = function()
|
|
|
257
243
|
"message": "Missing baseURL from request bound gitana-config"
|
|
258
244
|
});
|
|
259
245
|
}
|
|
246
|
+
|
|
260
247
|
proxyFactory.acquireProxyHandler(proxyTarget, null, function(err, proxyHandler) {
|
|
261
248
|
if (err) {
|
|
262
249
|
return next(err);
|