2018-08-19 01:55:53 +02:00
|
|
|
#!/bin/bash
|
2018-09-25 16:35:42 +02:00
|
|
|
### psql configuration parameters must be received as environ vars
|
|
|
|
### (PGHOST, PGDATABASE, PGUSER, PGPASSWORD)
|
2018-08-19 01:55:53 +02:00
|
|
|
timeout=60
|
|
|
|
for _ in $(seq 1 "$timeout"); do
|
2018-09-25 16:35:42 +02:00
|
|
|
if psql -w -c "" -q 2> /dev/null; then
|
2018-08-19 01:55:53 +02:00
|
|
|
echo "DB ready"
|
|
|
|
exec "$@"
|
|
|
|
fi
|
|
|
|
echo "Waiting..." >&2
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
echo "Timeout! postgresql wasn't ready in 60 seconds" >&2
|
|
|
|
exit 1
|