Skip to content

Commit caeaa78

Browse files
committed
feat: Update script to keep pinging Postgres until it's ready
1 parent 7bb6553 commit caeaa78

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

scripts/init_db.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,15 @@ docker run \
2222
-d postgres \
2323
postgres -N 1000
2424
# ^ Increased maximum number of connections for testing purposes
25+
26+
export PGPASSWORD="${DB_PASSWORD}"
27+
until psql -h "${DB_HOST}" -U "${DB_USER}" -p "${DB_PORT}" -d "postgres" -c '\q'; do
28+
>&2 echo "Postgres is still unavailable - sleeping"
29+
sleep 1
30+
done
31+
32+
>&2 echo "Postgres is up and running on port ${DB_PORT}!"
33+
34+
DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}
35+
export DATABASE_URL
36+
sqlx database create

0 commit comments

Comments
 (0)