2020-11-09 12:04:51 -05:00
|
|
|
/*
|
|
|
|
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('../../../')
|
2021-10-28 05:23:06 -04:00
|
|
|
const logger = require('@overleaf/logger')
|
2020-11-09 12:04:51 -05:00
|
|
|
|
|
|
|
const rclient = redis.createClient({
|
|
|
|
cluster: Array.from({ length: 9 }).map((value, index) => {
|
|
|
|
return { host: '127.0.0.1', port: 7000 + index }
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
|
|
|
|
setInterval(() => {
|
2021-12-16 04:04:32 -05:00
|
|
|
rclient.healthCheck(err => {
|
2020-11-09 12:04:51 -05:00
|
|
|
if (err) {
|
2020-11-10 04:40:38 -05:00
|
|
|
logger.error({ err }, 'HEALTH CHECK FAILED')
|
2020-11-09 12:04:51 -05:00
|
|
|
} else {
|
2020-11-10 04:40:38 -05:00
|
|
|
logger.log('HEALTH CHECK OK')
|
2020-11-09 12:04:51 -05:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}, 1000)
|