diff --git a/msa/tb/docker-postgres/start-db.sh b/msa/tb/docker-postgres/start-db.sh index 1688bba79e..94cb004012 100644 --- a/msa/tb/docker-postgres/start-db.sh +++ b/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 \ No newline at end of file +else + until pg_isready --dbname thingsboard --quiet + do + sleep 1 + echo "Waiting for db" + done +fi