Postgres startup script improved. will wait for postgres is ready about 300+ seconds. Postgres may do some recovery stuff on startup.
This commit is contained in:
parent
605c32123f
commit
4e0e1d3cae
@ -32,6 +32,13 @@ if [ ! -f ${firstlaunch} ]; then
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
else
|
||||
RETRIES="${PG_ISREADY_RETRIES:-300}"
|
||||
until pg_isready -U ${pkg.user} -d thingsboard --quiet || [ $RETRIES -eq 0 ]
|
||||
do
|
||||
echo "Connecting to Postgres, $((RETRIES--)) attempts left..."
|
||||
sleep 1
|
||||
done
|
||||
fi
|
||||
|
||||
cassandra_data_dir=${CASSANDRA_DATA}
|
||||
|
||||
@ -22,22 +22,21 @@ PG_CTL=$(find /usr/lib/postgresql/ -name pg_ctl)
|
||||
if [ ! -d ${PGDATA} ]; then
|
||||
mkdir -p ${PGDATA}
|
||||
${PG_CTL} initdb
|
||||
else
|
||||
${PG_CTL} start
|
||||
fi
|
||||
|
||||
exec setsid nohup postgres >> ${PGLOG}/postgres.log 2>&1 &
|
||||
|
||||
if [ ! -f ${firstlaunch} ]; then
|
||||
sleep 2
|
||||
while ! psql -U thingsboard -d postgres -c "CREATE DATABASE thingsboard"
|
||||
while ! psql -U ${pkg.user} -d postgres -c "CREATE DATABASE thingsboard"
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
else
|
||||
until pg_isready --dbname thingsboard --quiet
|
||||
RETRIES="${PG_ISREADY_RETRIES:-300}"
|
||||
until pg_isready -U ${pkg.user} -d thingsboard --quiet || [ $RETRIES -eq 0 ]
|
||||
do
|
||||
echo "Connecting to Postgres, $((RETRIES--)) attempts left..."
|
||||
sleep 1
|
||||
echo "Waiting for db"
|
||||
done
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user