mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Configure backend database as redis cluster
This commit is contained in:
parent
1db6f8f159
commit
ef43e2b325
12 changed files with 1765 additions and 5 deletions
5
services/document-updater/.gitignore
vendored
5
services/document-updater/.gitignore
vendored
|
@ -46,3 +46,8 @@ test/acceptance/js/*
|
|||
forever/
|
||||
|
||||
**.swp
|
||||
|
||||
# Redis cluster
|
||||
**/appendonly.aof
|
||||
**/dump.rdb
|
||||
**/nodes.conf
|
||||
|
|
|
@ -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)
|
|
@ -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}}"
|
||||
|
|
|
@ -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",
|
||||
|
|
5
services/document-updater/redis_cluster/7000/redis.conf
Normal file
5
services/document-updater/redis_cluster/7000/redis.conf
Normal file
|
@ -0,0 +1,5 @@
|
|||
port 7000
|
||||
cluster-enabled yes
|
||||
cluster-config-file nodes.conf
|
||||
cluster-node-timeout 5000
|
||||
appendonly yes
|
5
services/document-updater/redis_cluster/7001/redis.conf
Normal file
5
services/document-updater/redis_cluster/7001/redis.conf
Normal file
|
@ -0,0 +1,5 @@
|
|||
port 7001
|
||||
cluster-enabled yes
|
||||
cluster-config-file nodes.conf
|
||||
cluster-node-timeout 5000
|
||||
appendonly yes
|
5
services/document-updater/redis_cluster/7002/redis.conf
Normal file
5
services/document-updater/redis_cluster/7002/redis.conf
Normal file
|
@ -0,0 +1,5 @@
|
|||
port 7002
|
||||
cluster-enabled yes
|
||||
cluster-config-file nodes.conf
|
||||
cluster-node-timeout 5000
|
||||
appendonly yes
|
5
services/document-updater/redis_cluster/7003/redis.conf
Normal file
5
services/document-updater/redis_cluster/7003/redis.conf
Normal file
|
@ -0,0 +1,5 @@
|
|||
port 7003
|
||||
cluster-enabled yes
|
||||
cluster-config-file nodes.conf
|
||||
cluster-node-timeout 5000
|
||||
appendonly yes
|
5
services/document-updater/redis_cluster/7004/redis.conf
Normal file
5
services/document-updater/redis_cluster/7004/redis.conf
Normal file
|
@ -0,0 +1,5 @@
|
|||
port 7004
|
||||
cluster-enabled yes
|
||||
cluster-config-file nodes.conf
|
||||
cluster-node-timeout 5000
|
||||
appendonly yes
|
5
services/document-updater/redis_cluster/7005/redis.conf
Normal file
5
services/document-updater/redis_cluster/7005/redis.conf
Normal file
|
@ -0,0 +1,5 @@
|
|||
port 7005
|
||||
cluster-enabled yes
|
||||
cluster-config-file nodes.conf
|
||||
cluster-node-timeout 5000
|
||||
appendonly yes
|
23
services/document-updater/redis_cluster/redis-cluster.sh
Executable file
23
services/document-updater/redis_cluster/redis-cluster.sh
Executable 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
|
1696
services/document-updater/redis_cluster/redis-trib.rb
Executable file
1696
services/document-updater/redis_cluster/redis-trib.rb
Executable file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue