Browse Source

ensure postgres database is always started

The Postgres database would only get started on first launch. When starting a second time e.g. after a `docker-compose down` and `docker-compose up`, the database was not started resulting in a failure when ThingsBoard is starting.
pull/5771/head
André Kwakernaak 5 years ago
committed by GitHub
parent
commit
7d5153f52e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      msa/tb/docker-postgres/start-db.sh

12
msa/tb/docker-postgres/start-db.sh

@ -22,14 +22,22 @@ 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 ${pkg.user} -d postgres -c "CREATE DATABASE thingsboard"
while ! psql -U thingsboard -d postgres -c "CREATE DATABASE thingsboard"
do
sleep 1
done
fi
else
until pg_isready --dbname thingsboard --quiet
do
sleep 1
echo "Waiting for db"
done
fi

Loading…
Cancel
Save