#!/bin/bash

set -x

ip_address=$(hostname -i)
echo Attempting connection to postgres...
for _ in {1..60}; do
  gosu database pg_isready --host="$ip_address" && echo "Postgres connected!" && exit
  sleep 1
done
echo Postgres is still down after 60 seconds.
exit 1
