mirror of https://github.com/docker/docs.git
Merge pull request #12906 from ralpha/patch-1
Add comments to `wait-for-postgres.sh`
This commit is contained in:
commit
88b4505061
|
@ -68,14 +68,25 @@ script:
|
|||
set -e
|
||||
|
||||
host="$1"
|
||||
# Shift arguments with mapping:
|
||||
# - $0 => $0
|
||||
# - $1 => <discarded>
|
||||
# - $2 => $1
|
||||
# - $3 => $2
|
||||
# - ...
|
||||
# This is done for `exec "$@"` below to work correctly
|
||||
shift
|
||||
|
||||
# Login for user (`-U`) and once logged in execute quit ( `-c \q` )
|
||||
# If we can not login sleep for 1 sec
|
||||
until PGPASSWORD=$POSTGRES_PASSWORD psql -h "$host" -U "postgres" -c '\q'; do
|
||||
>&2 echo "Postgres is unavailable - sleeping"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
>&2 echo "Postgres is up - executing command"
|
||||
# Print and execute all other arguments starting with `$1`
|
||||
# So `exec "$1" "$2" "$3" ...`
|
||||
exec "$@"
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue