overleaf/libraries/redis-wrapper/test/scripts/cluster/cluster.js
Brian Gough d9d65ac31c Merge pull request #5246 from overleaf/bg-upgrade-logger-in-all-libraries
upgrade logger in libraries

GitOrigin-RevId: 5968f5abc5f77061cd90b5ebbccf86349619c4a7
2021-10-29 08:03:14 +00:00

26 lines
690 B
JavaScript

/*
execute this script with a redis cluster running to test the health check.
starting and stopping shards with this script running is a good test.
to create a new cluster, use $ ./create-redis-cluster.sh
to run a chaos monkey, use $ ./clear-dbs.sh
*/
const redis = require('../../../')
const logger = require('@overleaf/logger')
const rclient = redis.createClient({
cluster: Array.from({ length: 9 }).map((value, index) => {
return { host: '127.0.0.1', port: 7000 + index }
}),
})
setInterval(() => {
rclient.healthCheck((err) => {
if (err) {
logger.error({ err }, 'HEALTH CHECK FAILED')
} else {
logger.log('HEALTH CHECK OK')
}
})
}, 1000)