Postgres readyness check at one place in proxy instead of multiple

This commit is contained in:
kexkey
2021-12-01 10:59:01 -05:00
parent 66045234eb
commit 4d764a8dd0
2 changed files with 4 additions and 8 deletions

View File

@@ -2,10 +2,6 @@
. ./trace.sh . ./trace.sh
trace "[sqlmigrate20211105_0.7.0-0.8.0.sh] Waiting for PostgreSQL to be ready..."
while [ ! -f "/container_monitor/postgres_ready" ]; do echo "PostgreSQL not ready" ; sleep 10 ; done
trace "[sqlmigrate20211105_0.7.0-0.8.0.sh] PostgreSQL ready!"
trace "[sqlmigrate20211105_0.7.0-0.8.0.sh] Checking if postgres is set up..." trace "[sqlmigrate20211105_0.7.0-0.8.0.sh] Checking if postgres is set up..."
psql -h postgres -U cyphernode -c "\d" | grep "cyphernode_props" > /dev/null psql -h postgres -U cyphernode -c "\d" | grep "cyphernode_props" > /dev/null
if [ "$?" -eq "1" ]; then if [ "$?" -eq "1" ]; then

View File

@@ -34,13 +34,13 @@ else
rm -f /container_monitor/proxy_dbfailed rm -f /container_monitor/proxy_dbfailed
fi fi
trace "[startproxy] Waiting for PostgreSQL to be ready..."
while [ ! -f "/container_monitor/postgres_ready" ]; do echo "PostgreSQL not ready" ; sleep 10 ; done
trace "[startproxy] PostgreSQL ready!"
if [ ! -e ${DB_FILE} ]; then if [ ! -e ${DB_FILE} ]; then
trace "[startproxy] DB not found, creating..." trace "[startproxy] DB not found, creating..."
cat cyphernode.sql | sqlite3 $DB_FILE cat cyphernode.sql | sqlite3 $DB_FILE
trace "[startproxy] Waiting for PostgreSQL to be ready..."
while [ ! -f "/container_monitor/postgres_ready" ]; do echo "PostgreSQL not ready" ; sleep 10 ; done
trace "[startproxy] PostgreSQL ready!"
psql -h postgres -f cyphernode.postgresql -U cyphernode psql -h postgres -f cyphernode.postgresql -U cyphernode
returncode=$? returncode=$?
trace_rc ${returncode} trace_rc ${returncode}