cloudcms-server 0.9.255 → 0.9.256
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/locks/providers/redis.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var path = require("path");
|
|
2
2
|
var redis = require("redis");
|
|
3
3
|
var logFactory = require("../../util/logger");
|
|
4
|
+
var redisHelper = require("../../util/redis");
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Redis lock service.
|
|
@@ -38,31 +39,9 @@ exports = module.exports = function(locksConfig)
|
|
|
38
39
|
|
|
39
40
|
r.init = function(callback)
|
|
40
41
|
{
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
redisPort = process.env.CLOUDCMS_LOCKS_REDIS_PORT;
|
|
45
|
-
}
|
|
46
|
-
if (typeof(redisPort) === "undefined" || !redisPort)
|
|
47
|
-
{
|
|
48
|
-
redisPort = process.env.CLOUDCMS_REDIS_PORT;
|
|
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);
|
|
42
|
+
var redisOptions = redisHelper.redisOptions(locksConfig, "CLOUDCMS_LOCKS");
|
|
43
|
+
|
|
44
|
+
client = redis.createClient(redisOptions);
|
|
66
45
|
|
|
67
46
|
callback();
|
|
68
47
|
};
|
|
@@ -4,6 +4,7 @@ var redis = require("redis");
|
|
|
4
4
|
var async = require("async");
|
|
5
5
|
|
|
6
6
|
var logFactory = require("../../../util/logger");
|
|
7
|
+
var redisHelper = require("../../../util/redis");
|
|
7
8
|
|
|
8
9
|
class RedisProvider extends AbstractAsyncProvider
|
|
9
10
|
{
|
|
@@ -30,30 +31,10 @@ class RedisProvider extends AbstractAsyncProvider
|
|
|
30
31
|
init(callback)
|
|
31
32
|
{
|
|
32
33
|
var self = this;
|
|
34
|
+
|
|
35
|
+
var redisOptions = redisHelper.redisOptions(this.config, "CLOUDCMS_AWARENESS");
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
if (typeof(redisPort) === "undefined" || !redisPort)
|
|
36
|
-
{
|
|
37
|
-
redisPort = process.env.CLOUDCMS_AWARENESS_REDIS_PORT;
|
|
38
|
-
}
|
|
39
|
-
if (typeof(redisPort) === "undefined" || !redisPort)
|
|
40
|
-
{
|
|
41
|
-
redisPort = process.env.CLOUDCMS_REDIS_PORT;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var redisHost = this.config.host;
|
|
45
|
-
if (typeof(redisHost) === "undefined" || !redisHost)
|
|
46
|
-
{
|
|
47
|
-
redisHost = process.env.CLOUDCMS_AWARENESS_REDIS_ENDPOINT;
|
|
48
|
-
}
|
|
49
|
-
if (typeof(redisHost) === "undefined" || !redisHost)
|
|
50
|
-
{
|
|
51
|
-
redisHost = process.env.CLOUDCMS_REDIS_ENDPOINT;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
var redisOptions = {};
|
|
55
|
-
|
|
56
|
-
this.client = redis.createClient(redisPort, redisHost, redisOptions);
|
|
37
|
+
this.client = redis.createClient(redisOptions);
|
|
57
38
|
|
|
58
39
|
callback();
|
|
59
40
|
}
|
|
@@ -2,6 +2,7 @@ var path = require("path");
|
|
|
2
2
|
|
|
3
3
|
var redis = require("redis");
|
|
4
4
|
var logFactory = require("../../../util/logger");
|
|
5
|
+
const redisHelper = require("../../../util/redis");
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Redis distributed cache.
|
|
@@ -29,32 +30,12 @@ exports = module.exports = function(cacheConfig)
|
|
|
29
30
|
|
|
30
31
|
r.init = function(callback)
|
|
31
32
|
{
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
redisPort = process.env.CLOUDCMS_CACHE_REDIS_PORT;
|
|
36
|
-
}
|
|
37
|
-
if (typeof(redisPort) === "undefined" || !redisPort)
|
|
38
|
-
{
|
|
39
|
-
redisPort = process.env.CLOUDCMS_REDIS_PORT;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var redisEndpoint = cacheConfig.endpoint;
|
|
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);
|
|
33
|
+
var self = this;
|
|
34
|
+
|
|
35
|
+
var redisOptions = redisHelper.redisOptions(cacheConfig, "CLOUDCMS_CACHE");
|
|
57
36
|
|
|
37
|
+
client = redis.createClient(redisOptions);
|
|
38
|
+
|
|
58
39
|
callback();
|
|
59
40
|
};
|
|
60
41
|
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -23,6 +23,7 @@ const connectRedis = require('connect-redis');
|
|
|
23
23
|
var Passport = require("passport").Passport;
|
|
24
24
|
|
|
25
25
|
var util = require("../util/util");
|
|
26
|
+
var redisHelper = require("../util/redis");
|
|
26
27
|
|
|
27
28
|
var launchPad = require("../launchpad/index");
|
|
28
29
|
var cluster = require("cluster");
|
|
@@ -683,8 +684,8 @@ var startSlave = function(config, afterStartFn)
|
|
|
683
684
|
}
|
|
684
685
|
else
|
|
685
686
|
{
|
|
686
|
-
var redisOptions =
|
|
687
|
-
var redisClient = redis.createClient(
|
|
687
|
+
var redisOptions = redisHelper.redisOptions();
|
|
688
|
+
var redisClient = redis.createClient(redisOptions);
|
|
688
689
|
|
|
689
690
|
var RedisStore = connectRedis(session);
|
|
690
691
|
sessionConfig.store = new RedisStore({ client: redisClient });
|
package/util/redis.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
exports = module.exports;
|
|
2
|
+
|
|
3
|
+
var redisOptions = exports.redisOptions = function(config, prefix)
|
|
4
|
+
{
|
|
5
|
+
if (!config) {
|
|
6
|
+
config = {};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// redis port
|
|
10
|
+
var redisPort = config.port;
|
|
11
|
+
if (prefix)
|
|
12
|
+
{
|
|
13
|
+
if (typeof(redisPort) === "undefined" || !redisPort)
|
|
14
|
+
{
|
|
15
|
+
// CLOUDCMS_LOCKS_REDIS_PORT;
|
|
16
|
+
redisPort = process.env[prefix + "_REDIS_PORT"];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (typeof(redisPort) === "undefined" || !redisPort)
|
|
20
|
+
{
|
|
21
|
+
redisPort = process.env.CLOUDCMS_REDIS_PORT;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// redis host
|
|
25
|
+
var redisEndpoint = config.endpoint;
|
|
26
|
+
if (prefix)
|
|
27
|
+
{
|
|
28
|
+
if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
|
|
29
|
+
{
|
|
30
|
+
redisEndpoint = process.env[prefix + "_REDIS_ENDPOINT"];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
|
|
34
|
+
{
|
|
35
|
+
redisEndpoint = process.env.CLOUDCMS_REDIS_ENDPOINT;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// redis url
|
|
39
|
+
var redisUrl = config.url;
|
|
40
|
+
if (prefix)
|
|
41
|
+
{
|
|
42
|
+
if (typeof(redisUrl) === "undefined" || !redisUrl)
|
|
43
|
+
{
|
|
44
|
+
redisUrl = process.env[prefix + "_REDIS_URL"];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (typeof(redisUrl) === "undefined" || !redisUrl)
|
|
48
|
+
{
|
|
49
|
+
redisUrl = process.env.CLOUDCMS_REDIS_URL;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// build redis URL from components if not otherwise provided
|
|
53
|
+
if (!redisUrl)
|
|
54
|
+
{
|
|
55
|
+
redisUrl = "redis://" + redisEndpoint + ":" + redisPort;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var redisOptions = {};
|
|
59
|
+
redisOptions.url = redisUrl;
|
|
60
|
+
redisOptions.legacyMode = true;
|
|
61
|
+
|
|
62
|
+
return redisOptions;
|
|
63
|
+
}
|