initial commit
Change-Id: Ia748646eaf5c18f44eb5b147ff577d0d5ee844e8
This commit is contained in:
21
healthchecks/postgres.sh
Executable file
21
healthchecks/postgres.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
|
||||
host="$(hostname -i || echo '127.0.0.1')"
|
||||
user="${POSTGRES_USER:-postgres}"
|
||||
db="${POSTGRES_DB:-$POSTGRES_USER}"
|
||||
export PGPASSWORD="${POSTGRES_PASSWORD:-}"
|
||||
|
||||
args=(
|
||||
# force postgres to not use the local unix socket (test "external" connectibility)
|
||||
--host "$host"
|
||||
--username "$user"
|
||||
--dbname "$db"
|
||||
--quiet --no-align --tuples-only
|
||||
)
|
||||
|
||||
if select="$(echo 'SELECT 1' | psql "${args[@]}")" && [ "$select" = '1' ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exit 1
|
||||
Reference in New Issue
Block a user