Wait until postgres is available before attempting to run psql commands