dev: Clearer postgres error messages in postgres-init-dev-db.

This uses `pg_isready` to provide a clearer error message if postgres
isn't working.

Fixes #2419.
This commit is contained in:
Saumya Rawat
2016-12-20 01:15:02 +05:30
committed by Tim Abbott
parent dd37f9ab1f
commit 151d2139ad

View File

@@ -39,6 +39,15 @@ fi
DBNAME_BASE=${DBNAME}_base
if ! pg_isready -U "$DEFAULT_USER" -q; then
set +x
echo
echo 'ERROR: PostgreSQL Server is not running! Ensure the service is enabled.'
echo 'ERROR: Try `sudo service postgresql start`?'
echo "ERROR: You can easily test if you fixed it using: pg_isready -U \$DEFAULT_USER"
exit 1
fi
$ROOT_POSTGRES "$DEFAULT_DB" << EOF
CREATE USER $USERNAME;
ALTER USER $USERNAME PASSWORD '$PASSWORD';