cluster.js 643 B

12345678910111213141516171819202122232425
  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 rclient = redis.createClient({
  9. cluster: Array.from({ length: 9 }).map((value, index) => {
  10. return { host: '127.0.0.1', port: 7000 + index }
  11. }),
  12. })
  13. setInterval(() => {
  14. rclient.healthCheck((err) => {
  15. if (err) {
  16. console.log('HEALTH CHECK FAILED', err)
  17. } else {
  18. console.log('HEALTH CHECK OK')
  19. }
  20. })
  21. }, 1000)