From 151d2139ad966bf4e2a86b80dfa59f0efee61b49 Mon Sep 17 00:00:00 2001 From: Saumya Rawat Date: Tue, 20 Dec 2016 01:15:02 +0530 Subject: [PATCH] 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. --- tools/setup/postgres-init-dev-db | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/setup/postgres-init-dev-db b/tools/setup/postgres-init-dev-db index ddc0eba964..1388041884 100755 --- a/tools/setup/postgres-init-dev-db +++ b/tools/setup/postgres-init-dev-db @@ -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';