8

I have a health check I'm trying to use that executes the redis-cli command from the redis servers to the redis-sentinels remotely.

redis-cli -h 10.10.10.10 -p 26379 SENTINEL MASTER testing

There is a logic that sorts out whether there is a quorum and it all works fine unless a sentinel's network interface is unavailable. The redis-cli command hangs indefinitely in this case and the health check fails even though there are two healthy sentinels with a quorum.

I can't seem to find a way to set a timeout for the redis-cli on the client side to prevent it from hanging. Is there a way with redis-cli to do this or will I have to go outside the command to ensure it doesn't hang indefinitely?

numb3rs1x
  • 4,673
  • 5
  • 31
  • 44
  • I need to do the same thing in PowerShell. I'd prefer not to have to write a wrapper function, but I can't find a built-in timeout option in Redis. – Trevor Sullivan Oct 04 '22 at 21:06

1 Answers1

18

I decided to use the timeout command to wrap the redis-cli command. It seems to work very well for my purposes!

timeout 3 redis-cli -h 10.10.10.10 -p 26379 SENTINEL MASTER testing
numb3rs1x
  • 4,673
  • 5
  • 31
  • 44