Browse Source

mvp2 for redis-cluster

Henry Oswald 7 years ago
parent
commit
e3618acf20

+ 1 - 1
services/real-time/app.coffee

@@ -19,7 +19,7 @@ SessionSockets = require('session.socket.io')
 CookieParser = require("cookie-parser")
 
 
-
+sessionRedisClient.set "hello-a", "hello-there"
 
 DrainManager = require("./app/js/DrainManager")
 

+ 22 - 6
services/real-time/config/settings.defaults.coffee

@@ -1,4 +1,4 @@
-module.exports =
+settings =
 	redis:
 		realtime:
 			host: process.env['REAL_TIME_REDIS_HOST'] or process.env['REDIS_HOST'] or "localhost"
@@ -15,10 +15,9 @@ module.exports =
 			key_schema:
 				pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
 
-		websessions:
-			host: process.env['WEB_REDIS_HOST'] or process.env['REDIS_HOST'] or "localhost"
-			port: process.env['WEB_REDIS_PORT'] or process.env['REDIS_PORT'] or "6379"
-			password: process.env["WEB_REDIS_PASSWORD"] or process.env["REDIS_PASSWORD"] or ""
+		websessions: {}
+
+
 
 	internal:
 		realTime:
@@ -42,4 +41,21 @@ module.exports =
 	
 	max_doc_length: 2 * 1024 * 1024 # 2mb
 
-	forceDrainMsDelay: process.env['FORCE_DRAIN_MS_DELAY'] or false
+	forceDrainMsDelay: process.env['FORCE_DRAIN_MS_DELAY'] or false
+
+if process.env['REDIS_CLUSTER_ENABLED'] == "true"
+	settings.redis.websessions.cluster = [
+		{ host: process.env["SL_LIN_STAG_REDIS_3_SERVICE_HOST"], port: "6379" }
+	]
+	settings.redis.websessions.natMap =	{
+		'192.168.201.24:6379': { host: process.env["SL_LIN_STAG_REDIS_0_SERVICE_HOST"], port: "6379" }
+		'192.168.195.231:6379': { host: process.env["SL_LIN_STAG_REDIS_1_SERVICE_HOST"], port: "6379" }
+		'192.168.223.53:6379': { host: process.env["SL_LIN_STAG_REDIS_2_SERVICE_HOST"], port: "6379" }
+		'192.168.221.84:6379': { host: process.env["SL_LIN_STAG_REDIS_3_SERVICE_HOST"], port: "6379" }
+		'192.168.219.81:6379': { host: process.env["SL_LIN_STAG_REDIS_4_SERVICE_HOST"], port: "6379" }
+		'192.168.180.104:6379': { host: process.env["SL_LIN_STAG_REDIS_5_SERVICE_HOST"], port: "6379" }
+		'192.168.220.59:6379': { host: process.env["SL_LIN_STAG_REDIS_6_SERVICE_HOST"], port: "6379" }
+		'192.168.129.122:6379': { host: process.env["SL_LIN_STAG_REDIS_7_SERVICE_HOST"], port: "6379" }
+	}
+	
+module.exports = settings

+ 3 - 3
services/real-time/npm-shrinkwrap.json

@@ -1755,9 +1755,9 @@
       }
     },
     "redis-sharelatex": {
-      "version": "1.0.4",
-      "from": "git+https://github.com/sharelatex/redis-sharelatex.git#v1.0.4",
-      "resolved": "git+https://github.com/sharelatex/redis-sharelatex.git#ca4e906559c1405d132e8edd7db763d64a57be62",
+      "version": "511b59f3414d6e3db23a4b61239fd2cf3e07cdb0",
+      "from": "git+https://github.com/sharelatex/redis-sharelatex.git#511b59f3414d6e3db23a4b61239fd2cf3e07cdb0",
+      "resolved": "git+https://github.com/sharelatex/redis-sharelatex.git#511b59f3414d6e3db23a4b61239fd2cf3e07cdb0",
       "dependencies": {
         "async": {
           "version": "2.6.1",

+ 1 - 1
services/real-time/package.json

@@ -30,7 +30,7 @@
     "express-session": "^1.9.1",
     "logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.5.9",
     "metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v2.0.12",
-    "redis-sharelatex": "git+https://github.com/sharelatex/redis-sharelatex.git#v1.0.4",
+    "redis-sharelatex": "git+https://github.com/sharelatex/redis-sharelatex.git#511b59f3414d6e3db23a4b61239fd2cf3e07cdb0",
     "request": "~2.34.0",
     "session.socket.io": "^0.1.6",
     "settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.1.0",