Skip to content

Instantly share code, notes, and snippets.

@elbasan
Created March 4, 2022 19:08
Show Gist options
  • Save elbasan/1ebe1059daf07c3b19fe55c4d848fe19 to your computer and use it in GitHub Desktop.
Save elbasan/1ebe1059daf07c3b19fe55c4d848fe19 to your computer and use it in GitHub Desktop.
wait-for-redis
#!/usr/bin/env bash
hostport=(${1//:/ })
HOST=${hostport[0]}
PORT=${hostport[1]}
echo "Start waiting for Redis fully start. Host '$HOST', '$PORT'..."
echo "Try ping Redis... "
PONG=`redis-cli -h $HOST -p $PORT ping | grep PONG`
while [ -z "$PONG" ]; do
sleep 1
echo "Retry Redis ping... "
PONG=`redis-cli -h $HOST -p $PORT ping | grep PONG`
done
echo "Redis at host '$HOST', port '$PORT' fully started."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment