overleaf/libraries/redis-wrapper/test/scripts/cluster/cluster.js
Eric Mc Sween f0a3eeeb32 Merge pull request #7968 from overleaf/em-remove-logger-log
Remove logger.log in favour of logger.info

GitOrigin-RevId: e305ae8adf19ecf144cee123b6837f35d5d45bed
2022-05-17 08:05:39 +00:00

26 lines
689 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.info('HEALTH CHECK OK')
}
})
}, 1000)