Configure backend database as redis cluster

This commit is contained in:
James Allen 2016-06-07 18:38:32 +01:00
parent 1db6f8f159
commit ef43e2b325
12 changed files with 1765 additions and 5 deletions

View file

@ -46,3 +46,8 @@ test/acceptance/js/*
forever/
**.swp
# Redis cluster
**/appendonly.aof
**/dump.rdb
**/nodes.conf

View file

@ -1,5 +1,4 @@
Settings = require "settings-sharelatex"
redis = require("redis-sharelatex")
async = require "async"
class Client
@ -78,7 +77,12 @@ module.exports =
client_configs.primary = true
client_configs = [client_configs]
clients = client_configs.map (config) ->
rclient: redis.createClient(config)
if config.cluster?
Redis = require("ioredis")
rclient = new Redis.Cluster(config.cluster)
else
rclient = require("redis-sharelatex").createClient(config)
rclient: rclient
key_schema: config.key_schema
primary: config.primary
return new Client(clients)

View file

@ -34,9 +34,10 @@ module.exports =
pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
docsInProject: ({project_id}) -> "DocsIn:#{project_id}"
}, {
port: "6380"
host: "localhost"
password:""
cluster: [{
port: "7000"
host: "localhost"
}]
key_schema:
blockingKey: ({doc_id}) -> "Blocking:{#{doc_id}}"
docLines: ({doc_id}) -> "doclines:{#{doc_id}}"

View file

@ -10,6 +10,7 @@
"async": "^2.0.0-rc.5",
"coffee-script": "1.4.0",
"express": "3.3.4",
"ioredis": "^2.0.1",
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.0.0",
"lynx": "0.0.11",
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.0.0",

View file

@ -0,0 +1,5 @@
port 7000
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes

View file

@ -0,0 +1,5 @@
port 7001
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes

View file

@ -0,0 +1,5 @@
port 7002
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes

View file

@ -0,0 +1,5 @@
port 7003
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes

View file

@ -0,0 +1,5 @@
port 7004
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes

View file

@ -0,0 +1,5 @@
port 7005
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes

View file

@ -0,0 +1,23 @@
#!/bin/sh
(cd 7000 && redis-server redis.conf) &
PID1="$!"
(cd 7001 && redis-server redis.conf) &
PID2="$!"
(cd 7002 && redis-server redis.conf) &
PID3="$!"
(cd 7003 && redis-server redis.conf) &
PID4="$!"
(cd 7004 && redis-server redis.conf) &
PID5="$!"
(cd 7005 && redis-server redis.conf) &
PID6="$!"
trap "kill $PID1 $PID2 $PID3 $PID4 $PID5 $PID6" exit INT TERM
wait

File diff suppressed because it is too large Load diff