how to set a timeout for redis-cli command?
Asked Answered
T

1

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?

Taconite answered 7/7, 2016 at 19:0 Comment(1)
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.Agglutinogen
T
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
Taconite answered 7/7, 2016 at 19:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.