I would like a bash script that reads the stdout of a redis-cli subscribe and does something when a message is received, along with the message value.
The subscribe can be passed in as an arg to redis-cli like so
redis-cli --raw subscribe foo
but then I need to pipe that stdout to something so I can parse the messages. I thought about using a while read line; do loop but a single redis message takes up 3 lines.
update
My endgame is to announce a new redis master by setting a key on etcd. This should be achievable by subscribing to the switch-master channel on a redis sentinel. [1] The value of that message should be something along the lines of <master name> <oldip> <oldport> <newip> <newport> and I would like to set that newip as a value on etcd.
The command I would like to run when that message is received is etcdctl set /redis/master $NEWIP
[1] http://redis.io/topics/sentinel
because redis-cli subscribe output is currently buffered (https://github.com/antirez/redis/issues/2074) this isn't currently possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With