Created
February 8, 2023 11:06
-
-
Save InBrewJ/72bc8484bc1f553a0b8d7b7a0810d242 to your computer and use it in GitHub Desktop.
Minimal bash script to wait for postgres services in running in docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
is_ready_string="accepting connections" | |
postgres_ready=0 | |
timescale_ready=0 | |
all_postgres_are_ready=0 | |
echo $postgres_response | |
echo $timescale_response | |
while [ $all_postgres_are_ready -le 0 ] | |
do | |
sleep 1 | |
postgres_response=$(docker exec -ti postgres pg_isready) | |
timescale_response=$(docker exec -ti timescale pg_isready -U postgres) | |
if [[ "$postgres_response" == *"$is_ready_string"* ]]; then | |
echo "Local postgres is ready" | |
postgres_ready=1 | |
fi | |
if [[ "$timescale_response" == *"$is_ready_string"* ]]; then | |
echo "Local timescale is ready" | |
timescale_ready=1 | |
fi | |
if [ $postgres_ready -ge 1 ] && [ $timescale_ready -ge 1 ]; then | |
echo "All local postgres instances for udx-services are ready!" | |
all_postgres_are_ready=1 | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment