2020-11-09 17:04:51 +00: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 09:23:06 +00:00
|
|
|
const logger = require('@overleaf/logger')
|
2020-11-09 17:04:51 +00: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 09:04:32 +00:00
|
|
|
rclient.healthCheck(err => {
|
2020-11-09 17:04:51 +00:00
|
|
|
if (err) {
|
2020-11-10 09:40:38 +00:00
|
|
|
logger.error({ err }, 'HEALTH CHECK FAILED')
|
2020-11-09 17:04:51 +00:00
|
|
|
} else {
|
2022-05-16 12:40:25 +00:00
|
|
|
logger.info('HEALTH CHECK OK')
|
2020-11-09 17:04:51 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}, 1000)
|