Merge pull request #6719 from smatvienko-tb/postgres-await-startup
[3.4] Postgres await startup in docker containers with Postgres bundled
This commit is contained in:
commit
7e7f54319c
@ -24,16 +24,23 @@ if [ ! -d ${PGDATA} ]; then
|
|||||||
${PG_CTL} initdb
|
${PG_CTL} initdb
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec setsid nohup postgres >> ${PGLOG}/postgres.log 2>&1 &
|
echo "Starting Postgresql..."
|
||||||
|
${PG_CTL} start
|
||||||
|
|
||||||
|
RETRIES="${PG_ISREADY_RETRIES:-300}"
|
||||||
|
until pg_isready -U ${pkg.user} -d postgres --quiet || [ $RETRIES -eq 0 ]
|
||||||
|
do
|
||||||
|
echo "Connecting to Postgres, $((RETRIES--)) attempts left..."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
if [ ! -f ${firstlaunch} ]; then
|
if [ ! -f ${firstlaunch} ]; then
|
||||||
sleep 2
|
echo "Creating database..."
|
||||||
while ! psql -U ${pkg.user} -d postgres -c "CREATE DATABASE thingsboard"
|
psql -U ${pkg.user} -d postgres -c "CREATE DATABASE thingsboard"
|
||||||
do
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Postgresql is ready"
|
||||||
|
|
||||||
cassandra_data_dir=${CASSANDRA_DATA}
|
cassandra_data_dir=${CASSANDRA_DATA}
|
||||||
cassandra_data_link=/var/lib/cassandra
|
cassandra_data_link=/var/lib/cassandra
|
||||||
|
|
||||||
|
|||||||
@ -24,12 +24,19 @@ if [ ! -d ${PGDATA} ]; then
|
|||||||
${PG_CTL} initdb
|
${PG_CTL} initdb
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec setsid nohup postgres >> ${PGLOG}/postgres.log 2>&1 &
|
echo "Starting Postgresql..."
|
||||||
|
${PG_CTL} start
|
||||||
|
|
||||||
|
RETRIES="${PG_ISREADY_RETRIES:-300}"
|
||||||
|
until pg_isready -U ${pkg.user} -d postgres --quiet || [ $RETRIES -eq 0 ]
|
||||||
|
do
|
||||||
|
echo "Connecting to Postgres, $((RETRIES--)) attempts left..."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
if [ ! -f ${firstlaunch} ]; then
|
if [ ! -f ${firstlaunch} ]; then
|
||||||
sleep 2
|
echo "Creating database..."
|
||||||
while ! psql -U ${pkg.user} -d postgres -c "CREATE DATABASE thingsboard"
|
psql -U ${pkg.user} -d postgres -c "CREATE DATABASE thingsboard"
|
||||||
do
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Postgresql is ready"
|
||||||
@ -46,6 +46,8 @@ source "${CONF_FOLDER}/${configfile}"
|
|||||||
|
|
||||||
echo "Starting ThingsBoard installation ..."
|
echo "Starting ThingsBoard installation ..."
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardInstallApplication \
|
java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardInstallApplication \
|
||||||
-Dinstall.load_demo=${loadDemo} \
|
-Dinstall.load_demo=${loadDemo} \
|
||||||
-Dspring.jpa.hibernate.ddl-auto=none \
|
-Dspring.jpa.hibernate.ddl-auto=none \
|
||||||
|
|||||||
@ -25,15 +25,18 @@ firstlaunch=${DATA_FOLDER}/.firstlaunch
|
|||||||
source "${CONF_FOLDER}/${configfile}"
|
source "${CONF_FOLDER}/${configfile}"
|
||||||
|
|
||||||
if [ ! -f ${firstlaunch} ]; then
|
if [ ! -f ${firstlaunch} ]; then
|
||||||
install-tb.sh --loadDemo
|
install-tb.sh --loadDemo && touch ${firstlaunch}
|
||||||
touch ${firstlaunch}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting ThingsBoard ..."
|
if [ -f ${firstlaunch} ]; then
|
||||||
|
echo "Starting ThingsBoard ..."
|
||||||
|
|
||||||
java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardServerApplication \
|
java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardServerApplication \
|
||||||
-Dspring.jpa.hibernate.ddl-auto=none \
|
-Dspring.jpa.hibernate.ddl-auto=none \
|
||||||
-Dlogging.config=${CONF_FOLDER}/logback.xml \
|
-Dlogging.config=${CONF_FOLDER}/logback.xml \
|
||||||
org.springframework.boot.loader.PropertiesLauncher
|
org.springframework.boot.loader.PropertiesLauncher
|
||||||
|
else
|
||||||
|
echo "ERROR: ThingsBoard is not installed"
|
||||||
|
fi
|
||||||
|
|
||||||
stop-db.sh
|
stop-db.sh
|
||||||
Loading…
x
Reference in New Issue
Block a user