Compare commits

...

1 Commits

Author SHA1 Message Date
Kyle Wigley
03dfb11d2b wait for successful connection before setting up db 2021-09-13 11:43:17 -04:00

View File

@@ -12,23 +12,10 @@ PGPORT="${PGPORT:-5432}"
export PGPORT
PGHOST="${PGHOST:-localhost}"
function connect_circle() {
# try to handle circleci/docker oddness
let rc=1
while [[ $rc -eq 1 ]]; do
nc -z ${PGHOST} ${PGPORT}
let rc=$?
done
if [[ $rc -ne 0 ]]; then
echo "Fatal: Could not connect to $PGHOST"
exit 1
fi
}
# appveyor doesn't have 'nc', but it also doesn't have these issues
if [[ -n $CIRCLECI ]]; then
connect_circle
fi
until psql -h "$PGHOST" -c '\q'; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
createdb dbt
psql -c "CREATE ROLE root WITH PASSWORD 'password';"