cluster.js 689 B

1234567891011121314151617181920212223242526
  1. /*
  2. execute this script with a redis cluster running to test the health check.
  3. starting and stopping shards with this script running is a good test.
  4. to create a new cluster, use $ ./create-redis-cluster.sh
  5. to run a chaos monkey, use $ ./clear-dbs.sh
  6. */
  7. const redis = require('../../../')
  8. const logger = require('@overleaf/logger')
  9. const rclient = redis.createClient({
  10. cluster: Array.from({ length: 9 }).map((value, index) => {
  11. return { host: '127.0.0.1', port: 7000 + index }
  12. }),
  13. })
  14. setInterval(() => {
  15. rclient.healthCheck(err => {
  16. if (err) {
  17. logger.error({ err }, 'HEALTH CHECK FAILED')
  18. } else {
  19. logger.info('HEALTH CHECK OK')
  20. }
  21. })
  22. }, 1000)