cloudcms-server 0.9.301 → 3.3.1-beta.10
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/.last_command +7 -0
- package/broadcast/providers/redis.js +32 -57
- package/clients/nrp.js +117 -0
- package/clients/redis.js +48 -0
- package/duster/helpers/sample/nyt.js +5 -7
- package/framework/controllers.js +0 -1
- package/index.js +23 -13
- package/insight/insight.js +6 -9
- package/locks/providers/redis.js +29 -58
- package/middleware/admin/admin.js +4 -4
- package/middleware/awareness/awareness.js +4 -1
- package/middleware/awareness/plugins/editorial.js +41 -66
- package/middleware/awareness/plugins/resources.js +74 -0
- package/middleware/awareness/providers/redis.js +263 -237
- package/middleware/cache/providers/redis.js +134 -92
- package/middleware/config/config.js +41 -2
- package/middleware/deployment/deployment.js +19 -27
- package/middleware/form/form.js +18 -33
- package/middleware/modules/modules.js +64 -11
- package/middleware/proxy/proxy.js +1 -2
- package/middleware/stores/engines/s3.js +0 -2
- package/middleware/stores/stores.js +50 -6
- package/middleware/themes/themes.js +49 -0
- package/middleware/virtual-config/virtual-config.js +35 -39
- package/notifications/notifications.js +75 -2
- package/package.json +18 -20
- package/server/index.js +105 -23
- package/server/standalone.js +2 -0
- package/util/auth.js +5 -9
- package/util/cloudcms.js +19 -34
- package/util/proxy-factory.js +20 -8
- package/util/redis.js +113 -0
- package/util/renditions.js +6 -12
- package/util/request.js +117 -0
- package/util/util.js +31 -40
- package/web/socket.io/socket.io.js +4240 -2
- package/web/cms/ice.js +0 -109
- package/web/cms/preview.js +0 -106
package/.last_command
ADDED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
var
|
|
1
|
+
var redisClientFactory = require("../../clients/redis");
|
|
2
|
+
var redisHelper = require("../../util/redis");
|
|
2
3
|
|
|
3
|
-
var NRP = require(
|
|
4
|
-
|
|
5
|
-
var logFactory = require("../../util/logger");
|
|
4
|
+
var NRP = require("../../clients/nrp");
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Redis broadcast provider.
|
|
@@ -12,80 +11,56 @@ var logFactory = require("../../util/logger");
|
|
|
12
11
|
exports = module.exports = function(broadcastConfig)
|
|
13
12
|
{
|
|
14
13
|
var nrp = null;
|
|
15
|
-
|
|
16
|
-
var logger =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// allow for global redis default
|
|
20
|
-
// allow for redis broadcast specific
|
|
21
|
-
// otherwise default to "error"
|
|
22
|
-
if (typeof(process.env.CLOUDCMS_REDIS_DEBUG_LEVEL) !== "undefined") {
|
|
23
|
-
logger.setLevel(("" + process.env.CLOUDCMS_REDIS_DEBUG_LEVEL).toLowerCase(), true);
|
|
24
|
-
}
|
|
25
|
-
else if (typeof(process.env.CLOUDCMS_BROADCAST_REDIS_DEBUG_LEVEL) !== "undefined") {
|
|
26
|
-
logger.setLevel(("" + process.env.CLOUDCMS_BROADCAST_REDIS_DEBUG_LEVEL).toLowerCase(), true);
|
|
27
|
-
}
|
|
28
|
-
|
|
14
|
+
|
|
15
|
+
var logger = redisHelper.redisLogger("REDIS_BROADCAST", "CLOUDCMS_BROADCAST_", "error")
|
|
16
|
+
|
|
29
17
|
var r = {};
|
|
30
|
-
|
|
18
|
+
|
|
31
19
|
r.start = function(callback)
|
|
32
20
|
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
var nrpConfig = {
|
|
54
|
-
"port": redisPort,
|
|
55
|
-
"host": redisEndpoint,
|
|
56
|
-
"scope": "broadcast_cache"
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
logger.info("using config = " + nrpConfig);
|
|
60
|
-
|
|
61
|
-
nrp = new NRP(nrpConfig);
|
|
62
|
-
|
|
63
|
-
callback();
|
|
21
|
+
redisClientFactory.create(broadcastConfig, function(err, client) {
|
|
22
|
+
|
|
23
|
+
if (err) {
|
|
24
|
+
return callback(err);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var nrpConfig = {
|
|
28
|
+
"client": client,
|
|
29
|
+
"scope": "broadcast_cache"
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
logger.info("using config = " + nrpConfig);
|
|
33
|
+
|
|
34
|
+
nrp = new NRP(nrpConfig);
|
|
35
|
+
nrp.connect(function(err) {
|
|
36
|
+
callback(err);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
64
39
|
};
|
|
65
|
-
|
|
40
|
+
|
|
66
41
|
r.publish = function(topic, message, callback)
|
|
67
42
|
{
|
|
68
43
|
logger.info("publish. topic: " + topic + " message: " + message);
|
|
69
44
|
nrp.emit(topic, message);
|
|
70
|
-
|
|
45
|
+
|
|
71
46
|
callback();
|
|
72
47
|
};
|
|
73
|
-
|
|
48
|
+
|
|
74
49
|
r.subscribe = function(topic, fn, callback)
|
|
75
50
|
{
|
|
76
51
|
logger.info("subscribe. topic: " + topic);
|
|
77
52
|
nrp.on(topic, fn);
|
|
78
|
-
|
|
53
|
+
|
|
79
54
|
callback();
|
|
80
55
|
};
|
|
81
|
-
|
|
56
|
+
|
|
82
57
|
r.unsubscribe = function(topic, fn, callback)
|
|
83
58
|
{
|
|
84
59
|
logger.info("unsubscribe. topic: " + topic);
|
|
85
60
|
nrp.off(topic, fn);
|
|
86
|
-
|
|
61
|
+
|
|
87
62
|
callback();
|
|
88
63
|
};
|
|
89
|
-
|
|
64
|
+
|
|
90
65
|
return r;
|
|
91
66
|
};
|
package/clients/nrp.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// a revision of
|
|
2
|
+
// https://raw.githubusercontent.com/louischatriot/node-redis-pubsub/master/lib/node-redis-pubsub.js
|
|
3
|
+
// that works with Redis 6+
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
var redis = require('redis');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create a new NodeRedisPubsub instance that can subscribe to channels and publish messages
|
|
10
|
+
* @param {Object} options Options for the client creations:
|
|
11
|
+
* client - a connected Redis client
|
|
12
|
+
* scope - Optional, two NodeRedisPubsubs with different scopes will not share messages
|
|
13
|
+
*/
|
|
14
|
+
function NodeRedisPubsub(options)
|
|
15
|
+
{
|
|
16
|
+
if (!(this instanceof NodeRedisPubsub)){ return new NodeRedisPubsub(options); }
|
|
17
|
+
|
|
18
|
+
options || (options = {});
|
|
19
|
+
|
|
20
|
+
this.emitter = options.client.duplicate();
|
|
21
|
+
this.emitter.setMaxListeners(0);
|
|
22
|
+
this.receiver = options.client.duplicate();
|
|
23
|
+
this.receiver.setMaxListeners(0);
|
|
24
|
+
|
|
25
|
+
this.prefix = options.scope ? options.scope + ':' : '';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
NodeRedisPubsub.prototype.connect = function(callback)
|
|
29
|
+
{
|
|
30
|
+
var self = this;
|
|
31
|
+
|
|
32
|
+
(async function() {
|
|
33
|
+
await self.emitter.connect();
|
|
34
|
+
await self.receiver.connect();
|
|
35
|
+
callback();
|
|
36
|
+
})();
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Subscribe to a channel
|
|
41
|
+
* @param {String} channel The channel to subscribe to, can be a pattern e.g. 'user.*'
|
|
42
|
+
* @param {Function} handler Function to call with the received message.
|
|
43
|
+
* @param {Function} cb Optional callback to call once the handler is registered.
|
|
44
|
+
*/
|
|
45
|
+
NodeRedisPubsub.prototype.on = NodeRedisPubsub.prototype.subscribe = function(channel, handler, callback)
|
|
46
|
+
{
|
|
47
|
+
if (!callback)
|
|
48
|
+
{
|
|
49
|
+
callback = function(){};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var self = this;
|
|
53
|
+
|
|
54
|
+
if (channel === "error")
|
|
55
|
+
{
|
|
56
|
+
self.errorHandler = handler;
|
|
57
|
+
self.emitter.on("error", handler);
|
|
58
|
+
self.receiver.on("error", handler);
|
|
59
|
+
return callback();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var listener = function(self, handler)
|
|
63
|
+
{
|
|
64
|
+
return function(message, channel) {
|
|
65
|
+
|
|
66
|
+
var jsonmsg = message;
|
|
67
|
+
try{
|
|
68
|
+
jsonmsg = JSON.parse(message);
|
|
69
|
+
} catch (ex){
|
|
70
|
+
if(typeof self.errorHandler === 'function'){
|
|
71
|
+
return self.errorHandler("Invalid JSON received! Channel: " + self.prefix + channel + " Message: " + message);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return handler(jsonmsg, channel);
|
|
75
|
+
}
|
|
76
|
+
}(self, handler);
|
|
77
|
+
|
|
78
|
+
(async function() {
|
|
79
|
+
await self.receiver.pSubscribe(self.prefix + channel, listener);
|
|
80
|
+
})();
|
|
81
|
+
|
|
82
|
+
callback();
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Emit an event
|
|
87
|
+
* @param {String} channel Channel on which to emit the message
|
|
88
|
+
* @param {Object} message
|
|
89
|
+
*/
|
|
90
|
+
NodeRedisPubsub.prototype.emit = NodeRedisPubsub.prototype.publish = function (channel, message)
|
|
91
|
+
{
|
|
92
|
+
var self = this;
|
|
93
|
+
|
|
94
|
+
(async function() {
|
|
95
|
+
return await self.emitter.publish(self.prefix + channel, JSON.stringify(message));
|
|
96
|
+
})();
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Safely close the redis connections 'soon'
|
|
101
|
+
*/
|
|
102
|
+
NodeRedisPubsub.prototype.quit = function()
|
|
103
|
+
{
|
|
104
|
+
this.emitter.quit();
|
|
105
|
+
this.receiver.quit();
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Dangerously close the redis connections immediately
|
|
110
|
+
*/
|
|
111
|
+
NodeRedisPubsub.prototype.end = function()
|
|
112
|
+
{
|
|
113
|
+
this.emitter.end(true);
|
|
114
|
+
this.receiver.end(true);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
module.exports = NodeRedisPubsub;
|
package/clients/redis.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var redis = require("redis");
|
|
2
|
+
var redisHelper = require("../util/redis");
|
|
3
|
+
|
|
4
|
+
var clients = {};
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Redis client factory.
|
|
8
|
+
*
|
|
9
|
+
* @type {*}
|
|
10
|
+
*/
|
|
11
|
+
exports = module.exports = {};
|
|
12
|
+
|
|
13
|
+
var create = exports.create = function(config, callback)
|
|
14
|
+
{
|
|
15
|
+
if (typeof(config) === "function") {
|
|
16
|
+
callback = config;
|
|
17
|
+
config = {};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!config) {
|
|
21
|
+
config = {};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var redisOptions = redisHelper.redisOptions(config);
|
|
25
|
+
var url = redisOptions.url;
|
|
26
|
+
|
|
27
|
+
// cached client?
|
|
28
|
+
var client = clients[url];
|
|
29
|
+
if (client) {
|
|
30
|
+
return callback(null, client);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// connect
|
|
34
|
+
(async function() {
|
|
35
|
+
await redisHelper.createAndConnect(redisOptions, function(err, client) {
|
|
36
|
+
|
|
37
|
+
if (err) {
|
|
38
|
+
return callback(err);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// cache it
|
|
42
|
+
clients[url] = client;
|
|
43
|
+
|
|
44
|
+
// return
|
|
45
|
+
return callback(null, client);
|
|
46
|
+
});
|
|
47
|
+
})();
|
|
48
|
+
};
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
exports = module.exports = function(app, dust, callback)
|
|
7
7
|
{
|
|
8
8
|
var support = require("../support")(dust);
|
|
9
|
+
var request = require("../../util/request");
|
|
9
10
|
|
|
10
11
|
// helper functions
|
|
11
12
|
var isDefined = support.isDefined;
|
|
@@ -49,7 +50,6 @@ exports = module.exports = function(app, dust, callback)
|
|
|
49
50
|
return map(chunk, function(chunk) {
|
|
50
51
|
setTimeout(function() {
|
|
51
52
|
|
|
52
|
-
var request = require("request");
|
|
53
53
|
var API_KEY = "3d8d573ec0ae966ea57245357cfcf57f:1:70698955";
|
|
54
54
|
|
|
55
55
|
var url = "http://api.nytimes.com/svc/events/v2/listings.json?api-key=" + API_KEY;
|
|
@@ -77,17 +77,16 @@ exports = module.exports = function(app, dust, callback)
|
|
|
77
77
|
|
|
78
78
|
//console.log("URL:" + url);
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
request(url, function (error, response, body) {
|
|
80
|
+
request(url, function (error, response, json) {
|
|
82
81
|
|
|
83
|
-
if (error || response.
|
|
82
|
+
if (error || response.status !== 200)
|
|
84
83
|
{
|
|
85
84
|
if (error) {
|
|
86
85
|
console.log("ERROR: " + error);
|
|
87
86
|
}
|
|
88
87
|
|
|
89
|
-
if (response.
|
|
90
|
-
console.log("STATUS CODE: " + response.
|
|
88
|
+
if (response.status !== 200) {
|
|
89
|
+
console.log("STATUS CODE: " + response.status);
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
chunk.write("There was an error loading this section");
|
|
@@ -96,7 +95,6 @@ exports = module.exports = function(app, dust, callback)
|
|
|
96
95
|
return;
|
|
97
96
|
}
|
|
98
97
|
|
|
99
|
-
var json = JSON.parse(body);
|
|
100
98
|
console.log("BODY: " + JSON.stringify(json, null, " "));
|
|
101
99
|
|
|
102
100
|
var resultObject = {
|
package/framework/controllers.js
CHANGED
package/index.js
CHANGED
|
@@ -34,7 +34,7 @@ process.logInfo = process.log = function(text, level)
|
|
|
34
34
|
var Gitana = require("gitana");
|
|
35
35
|
|
|
36
36
|
// default http timeout
|
|
37
|
-
process.defaultHttpTimeoutMs =
|
|
37
|
+
process.defaultHttpTimeoutMs = 60000;
|
|
38
38
|
|
|
39
39
|
if (process.env.DEFAULT_HTTP_TIMEOUT_MS)
|
|
40
40
|
{
|
|
@@ -54,20 +54,18 @@ var HttpsKeepAliveAgent = require('agentkeepalive').HttpsAgent;
|
|
|
54
54
|
http.globalAgent = new HttpKeepAliveAgent({
|
|
55
55
|
keepAlive: true,
|
|
56
56
|
keepAliveMsecs: 1000,
|
|
57
|
-
|
|
57
|
+
maxSockets: 16000,
|
|
58
|
+
maxFreeSockets: 256,
|
|
58
59
|
timeout: process.defaultHttpTimeoutMs,
|
|
59
|
-
|
|
60
|
-
maxFreeSockets: 40,
|
|
61
|
-
rejectUnauthorized: false
|
|
60
|
+
freeSocketTimeout: 30000
|
|
62
61
|
});
|
|
63
62
|
https.globalAgent = new HttpsKeepAliveAgent({
|
|
64
63
|
keepAlive: true,
|
|
65
64
|
keepAliveMsecs: 1000,
|
|
66
|
-
|
|
65
|
+
maxSockets: 16000,
|
|
66
|
+
maxFreeSockets: 256,
|
|
67
67
|
timeout: process.defaultHttpTimeoutMs,
|
|
68
|
-
|
|
69
|
-
maxFreeSockets: 40,
|
|
70
|
-
rejectUnauthorized: false
|
|
68
|
+
freeSocketTimeout: 30000
|
|
71
69
|
});
|
|
72
70
|
|
|
73
71
|
// disable for now
|
|
@@ -126,7 +124,7 @@ exports = module.exports = function()
|
|
|
126
124
|
// TODO: this is to disable really annoying Express 3.0 deprecated's for multipart() which should hopefully
|
|
127
125
|
// TODO: be resolved soon
|
|
128
126
|
console.warn = function() {};
|
|
129
|
-
|
|
127
|
+
|
|
130
128
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
131
129
|
|
|
132
130
|
// assume app-server base path if none provided
|
|
@@ -139,6 +137,7 @@ exports = module.exports = function()
|
|
|
139
137
|
var defaultGitanaProxyScheme = "https";
|
|
140
138
|
var defaultGitanaProxyHost = "api.cloudcms.com";
|
|
141
139
|
var defaultGitanaProxyPort = 443;
|
|
140
|
+
var defaultGitanaProxyPath = "";
|
|
142
141
|
|
|
143
142
|
var gitanaJsonPath = path.join(process.env.CLOUDCMS_APPSERVER_BASE_PATH, "gitana.json");
|
|
144
143
|
if (fs.existsSync(gitanaJsonPath))
|
|
@@ -150,6 +149,7 @@ exports = module.exports = function()
|
|
|
150
149
|
|
|
151
150
|
defaultGitanaProxyHost = parsedUrl.hostname;
|
|
152
151
|
defaultGitanaProxyScheme = parsedUrl.protocol.substring(0, parsedUrl.protocol.length - 1); // remove the :
|
|
152
|
+
defaultGitanaProxyPath = parsedUrl.path;
|
|
153
153
|
|
|
154
154
|
if (parsedUrl.port)
|
|
155
155
|
{
|
|
@@ -176,10 +176,13 @@ exports = module.exports = function()
|
|
|
176
176
|
if (!process.env.GITANA_PROXY_PORT) {
|
|
177
177
|
process.env.GITANA_PROXY_PORT = defaultGitanaProxyPort;
|
|
178
178
|
}
|
|
179
|
-
|
|
179
|
+
if (!process.env.GITANA_PROXY_PATH) {
|
|
180
|
+
process.env.GITANA_PROXY_PATH = defaultGitanaProxyPath;
|
|
181
|
+
}
|
|
182
|
+
|
|
180
183
|
if (cluster.isMaster)
|
|
181
184
|
{
|
|
182
|
-
process.log("Gitana Proxy pointed to: " + util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT));
|
|
185
|
+
process.log("Gitana Proxy pointed to: " + util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH));
|
|
183
186
|
}
|
|
184
187
|
|
|
185
188
|
// all web modules are included by default
|
|
@@ -218,6 +221,7 @@ exports = module.exports = function()
|
|
|
218
221
|
var serverTags = require("./middleware/server-tags/server-tags");
|
|
219
222
|
var storeService = require("./middleware/stores/stores");
|
|
220
223
|
var templates = require("./middleware/templates/templates");
|
|
224
|
+
var themes = require("./middleware/themes/themes");
|
|
221
225
|
var virtualConfig = require("./middleware/virtual-config/virtual-config");
|
|
222
226
|
var virtualFiles = require("./middleware/virtual-files/virtual-files");
|
|
223
227
|
var wcm = require("./middleware/wcm/wcm");
|
|
@@ -491,6 +495,9 @@ exports = module.exports = function()
|
|
|
491
495
|
// handles deploy/undeploy commands
|
|
492
496
|
app.use(deployment.handler());
|
|
493
497
|
|
|
498
|
+
// supports invalidation of configuration
|
|
499
|
+
app.use(config.invalidateConfigHandler());
|
|
500
|
+
|
|
494
501
|
// serve back static configuration
|
|
495
502
|
app.use(config.staticConfigHandler());
|
|
496
503
|
|
|
@@ -499,7 +506,10 @@ exports = module.exports = function()
|
|
|
499
506
|
|
|
500
507
|
// handles calls to the templates service
|
|
501
508
|
app.use(templates.handler());
|
|
502
|
-
|
|
509
|
+
|
|
510
|
+
// handles calls to the themes service
|
|
511
|
+
app.use(themes.handler());
|
|
512
|
+
|
|
503
513
|
// handles calls to the modules service
|
|
504
514
|
app.use(modules.handler());
|
|
505
515
|
|
package/insight/insight.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var http = require("http");
|
|
2
|
-
var path = require("path");
|
|
3
|
-
var request = require("request");
|
|
4
1
|
var util = require("../util/util");
|
|
5
2
|
|
|
6
3
|
/**
|
|
@@ -131,7 +128,7 @@ var doSend = function(callback)
|
|
|
131
128
|
}
|
|
132
129
|
|
|
133
130
|
// url over to cloud cms
|
|
134
|
-
var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/warehouses/" + warehouseId + "/interactions/_create";
|
|
131
|
+
var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/warehouses/" + warehouseId + "/interactions/_create";
|
|
135
132
|
var requestConfig = {
|
|
136
133
|
"url": URL,
|
|
137
134
|
"qs": {},
|
|
@@ -145,15 +142,15 @@ var doSend = function(callback)
|
|
|
145
142
|
|
|
146
143
|
// make a single attempt to send the data over
|
|
147
144
|
// if it fails, we add it back to the queue
|
|
148
|
-
util.retryGitanaRequest(log, gitana, requestConfig, 1, function(err, response,
|
|
145
|
+
util.retryGitanaRequest(log, gitana, requestConfig, 1, function(err, response, json) {
|
|
149
146
|
|
|
150
|
-
if (response && response.
|
|
147
|
+
if (response && response.status === 200 && json)
|
|
151
148
|
{
|
|
152
149
|
console.log("Insight sync for warehouse: " + warehouseId + " succeeded");
|
|
153
150
|
}
|
|
154
151
|
else
|
|
155
152
|
{
|
|
156
|
-
if (err || (
|
|
153
|
+
if (err || (json && json.error))
|
|
157
154
|
{
|
|
158
155
|
console.log("Insight sync for warehouse: " + warehouseId + " failed");
|
|
159
156
|
|
|
@@ -169,9 +166,9 @@ var doSend = function(callback)
|
|
|
169
166
|
}
|
|
170
167
|
*/
|
|
171
168
|
|
|
172
|
-
if (
|
|
169
|
+
if (json && json.error)
|
|
173
170
|
{
|
|
174
|
-
console.log(" -> body: " + JSON.stringify(
|
|
171
|
+
console.log(" -> body: " + JSON.stringify(json));
|
|
175
172
|
}
|
|
176
173
|
}
|
|
177
174
|
}
|
package/locks/providers/redis.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
var path = require("path");
|
|
2
|
-
var redis = require("redis");
|
|
3
1
|
var logFactory = require("../../util/logger");
|
|
2
|
+
//var redisHelper = require("../../util/redis");
|
|
3
|
+
|
|
4
|
+
var redisClientFactory = require("../../clients/redis");
|
|
5
|
+
const redisHelper = require("../../util/redis");
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Redis lock service.
|
|
@@ -15,94 +17,63 @@ exports = module.exports = function(locksConfig)
|
|
|
15
17
|
retries: 2000,
|
|
16
18
|
delay: 50
|
|
17
19
|
});
|
|
18
|
-
|
|
19
|
-
var nrp = null;
|
|
20
|
+
|
|
20
21
|
var client = null;
|
|
21
|
-
|
|
22
|
-
var logger =
|
|
23
|
-
|
|
24
|
-
// allow for global redis default
|
|
25
|
-
// allow for redis broadcast specific
|
|
26
|
-
// otherwise default to error
|
|
27
|
-
if (typeof(process.env.CLOUDCMS_REDIS_DEBUG_LEVEL) !== "undefined") {
|
|
28
|
-
logger.setLevel(("" + process.env.CLOUDCMS_REDIS_DEBUG_LEVEL).toLowerCase(), true);
|
|
29
|
-
}
|
|
30
|
-
else if (typeof(process.env.CLOUDCMS_LOCKS_REDIS_DEBUG_LEVEL) !== "undefined") {
|
|
31
|
-
logger.setLevel(("" + process.env.CLOUDCMS_LOCKS_REDIS_DEBUG_LEVEL).toLowerCase(), true);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
logger.setLevel("error");
|
|
35
|
-
}
|
|
36
|
-
|
|
22
|
+
|
|
23
|
+
var logger = redisHelper.redisLogger("REDIS_LOCKS", "CLOUDCMS_LOCKS_", "error")
|
|
24
|
+
|
|
37
25
|
var r = {};
|
|
38
|
-
|
|
26
|
+
|
|
39
27
|
r.init = function(callback)
|
|
40
28
|
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var redisEndpoint = locksConfig.endpoint;
|
|
52
|
-
if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
|
|
53
|
-
{
|
|
54
|
-
redisEndpoint = process.env.CLOUDCMS_LOCKS_REDIS_ENDPOINT;
|
|
55
|
-
}
|
|
56
|
-
if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
|
|
57
|
-
{
|
|
58
|
-
redisEndpoint = process.env.CLOUDCMS_REDIS_ENDPOINT;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
var redisOptions = {};
|
|
62
|
-
|
|
63
|
-
//redis.debug_mode = true;
|
|
64
|
-
|
|
65
|
-
client = redis.createClient(redisPort, redisEndpoint, redisOptions);
|
|
66
|
-
|
|
67
|
-
callback();
|
|
29
|
+
redisClientFactory.create(locksConfig, function(err, _client) {
|
|
30
|
+
|
|
31
|
+
if (err) {
|
|
32
|
+
return callback(err);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
client = _client;
|
|
36
|
+
|
|
37
|
+
return callback();
|
|
38
|
+
});
|
|
68
39
|
};
|
|
69
|
-
|
|
40
|
+
|
|
70
41
|
r.lock = function(key, fn)
|
|
71
42
|
{
|
|
72
43
|
var lockKey = "cloudcms:locks:write:" + key;
|
|
73
|
-
|
|
44
|
+
|
|
74
45
|
var lock = redisLock.createLock(client);
|
|
75
|
-
|
|
46
|
+
|
|
76
47
|
var releaseCallbackFn = function(lock, lockKey) {
|
|
77
48
|
return function() {
|
|
78
49
|
logger.info("lock.release - " + lockKey);
|
|
79
50
|
lock.release(function(err) {
|
|
80
|
-
|
|
51
|
+
|
|
81
52
|
if (err) {
|
|
82
53
|
console.log("Failed to release redis lock: " + lockKey);
|
|
83
54
|
console.log("Error: " + err);
|
|
84
55
|
return;
|
|
85
56
|
}
|
|
86
|
-
|
|
57
|
+
|
|
87
58
|
logger.info("lock.released - " + lockKey);
|
|
88
59
|
});
|
|
89
60
|
}
|
|
90
61
|
}(lock, lockKey);
|
|
91
|
-
|
|
62
|
+
|
|
92
63
|
logger.info("lock.acquire - " + lockKey);
|
|
93
64
|
lock.acquire(lockKey, function(err) {
|
|
94
|
-
|
|
65
|
+
|
|
95
66
|
if (err) {
|
|
96
67
|
console.log("Failed to acquire redis lock: " + lockKey);
|
|
97
68
|
console.log("Error: " + err);
|
|
98
69
|
return;
|
|
99
70
|
}
|
|
100
|
-
|
|
71
|
+
|
|
101
72
|
logger.info("lock.acquired - " + lockKey);
|
|
102
|
-
|
|
73
|
+
|
|
103
74
|
fn(releaseCallbackFn);
|
|
104
75
|
});
|
|
105
76
|
};
|
|
106
|
-
|
|
77
|
+
|
|
107
78
|
return r;
|
|
108
79
|
};
|
|
@@ -17,8 +17,8 @@ exports = module.exports = function()
|
|
|
17
17
|
if (ref)
|
|
18
18
|
{
|
|
19
19
|
var z = ref.indexOf("://");
|
|
20
|
-
|
|
21
|
-
var type = ref.substring(0, z
|
|
20
|
+
|
|
21
|
+
var type = ref.substring(0, z);
|
|
22
22
|
var identifier = ref.substring(z + 3);
|
|
23
23
|
|
|
24
24
|
var parts = identifier.split("/").reverse();
|
|
@@ -131,8 +131,8 @@ exports = module.exports = function()
|
|
|
131
131
|
if (req.url.indexOf("/_admin/cache/reset") === 0 || req.url.indexOf("/_admin/cache/invalidate") === 0)
|
|
132
132
|
{
|
|
133
133
|
assertAuthenticated(req, res, function() {
|
|
134
|
-
|
|
135
|
-
doResetCache(req.virtualHost, req.ref, function(err) {
|
|
134
|
+
|
|
135
|
+
doResetCache(req.virtualHost, req.query.ref, function(err) {
|
|
136
136
|
completionFn(req.virtualHost, res, err);
|
|
137
137
|
});
|
|
138
138
|
|
|
@@ -14,7 +14,10 @@ exports = module.exports = function()
|
|
|
14
14
|
var REAP_FREQUENCY_MS = 3000; // three seconds
|
|
15
15
|
var REAP_MAX_AGE_MS = 5000; // five seconds
|
|
16
16
|
|
|
17
|
-
var pluginPaths = [
|
|
17
|
+
var pluginPaths = [
|
|
18
|
+
"./plugins/editorial",
|
|
19
|
+
"./plugins/resources"
|
|
20
|
+
];
|
|
18
21
|
var plugins = {};
|
|
19
22
|
|
|
20
23
|
// ensure reaper only initializes once
|