optimize pgpool healthcheck (#64)
* optimize pgpool helthcheck avoid to get "SHOW pool_nodes;" twice * Update 4/debian-10/rootfs/opt/bitnami/scripts/libpgpool.sh Co-authored-by: Miguel Ángel Cabrera Miñagorri <devgorri@gmail.com> Co-authored-by: Miguel Ángel Cabrera Miñagorri <devgorri@gmail.com>
This commit is contained in:
parent
1d6c52f7d7
commit
2f9cd22396
|
|
@ -275,11 +275,11 @@ pgpool_attach_node() {
|
|||
#########################
|
||||
pgpool_healthcheck() {
|
||||
info "Checking pgpool health..."
|
||||
if PGCONNECT_TIMEOUT=15 PGPASSWORD="${PGPOOL_POSTGRES_PASSWORD}" psql -U "${PGPOOL_POSTGRES_USERNAME}" -d postgres \
|
||||
-h "${PGPOOL_TMP_DIR}" -p "${PGPOOL_PORT_NUMBER}" -tA -c "SHOW pool_nodes;" >/dev/null; then
|
||||
# look up backiends that are marked offline
|
||||
for node in $(PGPASSWORD="${PGPOOL_POSTGRES_PASSWORD}" psql -U "${PGPOOL_POSTGRES_USERNAME}" -d postgres \
|
||||
-h "${PGPOOL_TMP_DIR}" -p "${PGPOOL_PORT_NUMBER}" -tA -c "SHOW pool_nodes;" | grep "down" | tr -d ' ' ); do
|
||||
local backends=$(PGCONNECT_TIMEOUT=15 PGPASSWORD="${PGPOOL_POSTGRES_PASSWORD}" psql -U "${PGPOOL_POSTGRES_USERNAME}" \
|
||||
-d postgres -h "${PGPOOL_TMP_DIR}" -p "${PGPOOL_PORT_NUMBER}" -tA -c "SHOW pool_nodes;" | tr -d ' ')
|
||||
if [[ "$backends" ]]; then
|
||||
# look up backends that are marked offline
|
||||
for node in $(echo "${backends}" | grep "down"); do
|
||||
node_id=$(echo "${node}" | cut -d'|' -f1)
|
||||
node_host=$(echo "${node}" | cut -d'|' -f2)
|
||||
if [[ $(PGCONNECT_TIMEOUT=3 PGPASSWORD="${PGPOOL_POSTGRES_PASSWORD}" psql -U "${PGPOOL_POSTGRES_USERNAME}" \
|
||||
|
|
|
|||
Loading…
Reference in New Issue