Fixed PostgreSQL availability check

This commit is contained in:
Alexey Pustovalov 2020-07-29 23:10:48 -04:00
parent 7436513ee1
commit 17451c107f
3 changed files with 7 additions and 7 deletions

View File

@ -186,7 +186,7 @@ check_db_connect_postgresql() {
export PGOPTIONS
fi
while [ ! "$(psql --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --list --quiet 2>/dev/null)" ]; do
while [ ! "$(pg_isready --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --dbname ${DB_SERVER_DBNAME} --quiet 2>/dev/null && echo $?)" ]; do
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
sleep $WAIT_TIMEOUT
done
@ -204,7 +204,7 @@ psql_query() {
if [ -n "${DB_SERVER_ZBX_PASS}" ]; then
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
fi
if [ -n "${DB_SERVER_SCHEMA}" ]; then
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
export PGOPTIONS
@ -269,7 +269,7 @@ create_db_schema_postgresql() {
zcat /usr/share/doc/zabbix-server-postgresql/create.sql.gz | psql --quiet \
--host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} \
--username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null
--username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null || exit 1
unset PGPASSWORD
unset PGOPTIONS

View File

@ -186,7 +186,7 @@ check_db_connect_postgresql() {
export PGOPTIONS
fi
while [ ! "$(psql --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --list --quiet 2>/dev/null)" ]; do
while [ ! "$(pg_isready --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --dbname ${DB_SERVER_DBNAME} --quiet 2>/dev/null && echo $?)" ]; do
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
sleep $WAIT_TIMEOUT
done
@ -269,7 +269,7 @@ create_db_schema_postgresql() {
zcat /usr/share/doc/zabbix-server-postgresql/create.sql.gz | psql --quiet \
--host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} \
--username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null
--username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null || exit 1
unset PGPASSWORD
unset PGOPTIONS

View File

@ -186,7 +186,7 @@ check_db_connect_postgresql() {
export PGOPTIONS
fi
while [ ! "$(psql --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --list --quiet 2>/dev/null)" ]; do
while [ ! "$(pg_isready --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --dbname ${DB_SERVER_DBNAME} --quiet 2>/dev/null && echo $?)" ]; do
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
sleep $WAIT_TIMEOUT
done
@ -269,7 +269,7 @@ create_db_schema_postgresql() {
zcat /usr/share/doc/zabbix-server-postgresql/create.sql.gz | psql --quiet \
--host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} \
--username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null
--username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null || exit 1
unset PGPASSWORD
unset PGOPTIONS