Browse Source
Merge pull request #6719 from smatvienko-tb/postgres-await-startup
[3.4] Postgres await startup in docker containers with Postgres bundled
pull/6731/head
Igor Kulikov
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
39 additions and
20 deletions
-
msa/tb/docker-cassandra/start-db.sh
-
msa/tb/docker-postgres/start-db.sh
-
msa/tb/docker/install-tb.sh
-
msa/tb/docker/start-tb.sh
|
|
|
@ -24,16 +24,23 @@ if [ ! -d ${PGDATA} ]; then |
|
|
|
${PG_CTL} initdb |
|
|
|
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 |
|
|
|
sleep 2 |
|
|
|
while ! psql -U ${pkg.user} -d postgres -c "CREATE DATABASE thingsboard" |
|
|
|
do |
|
|
|
sleep 1 |
|
|
|
done |
|
|
|
echo "Creating database..." |
|
|
|
psql -U ${pkg.user} -d postgres -c "CREATE DATABASE thingsboard" |
|
|
|
fi |
|
|
|
|
|
|
|
echo "Postgresql is ready" |
|
|
|
|
|
|
|
cassandra_data_dir=${CASSANDRA_DATA} |
|
|
|
cassandra_data_link=/var/lib/cassandra |
|
|
|
|
|
|
|
|
|
|
|
@ -24,12 +24,19 @@ if [ ! -d ${PGDATA} ]; then |
|
|
|
${PG_CTL} initdb |
|
|
|
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 |
|
|
|
sleep 2 |
|
|
|
while ! psql -U ${pkg.user} -d postgres -c "CREATE DATABASE thingsboard" |
|
|
|
do |
|
|
|
sleep 1 |
|
|
|
done |
|
|
|
fi |
|
|
|
echo "Creating database..." |
|
|
|
psql -U ${pkg.user} -d postgres -c "CREATE DATABASE thingsboard" |
|
|
|
fi |
|
|
|
|
|
|
|
echo "Postgresql is ready" |
|
|
|
@ -46,6 +46,8 @@ source "${CONF_FOLDER}/${configfile}" |
|
|
|
|
|
|
|
echo "Starting ThingsBoard installation ..." |
|
|
|
|
|
|
|
set -e |
|
|
|
|
|
|
|
java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardInstallApplication \ |
|
|
|
-Dinstall.load_demo=${loadDemo} \ |
|
|
|
-Dspring.jpa.hibernate.ddl-auto=none \ |
|
|
|
|
|
|
|
@ -25,15 +25,18 @@ firstlaunch=${DATA_FOLDER}/.firstlaunch |
|
|
|
source "${CONF_FOLDER}/${configfile}" |
|
|
|
|
|
|
|
if [ ! -f ${firstlaunch} ]; then |
|
|
|
install-tb.sh --loadDemo |
|
|
|
touch ${firstlaunch} |
|
|
|
install-tb.sh --loadDemo && touch ${firstlaunch} |
|
|
|
fi |
|
|
|
|
|
|
|
echo "Starting ThingsBoard ..." |
|
|
|
if [ -f ${firstlaunch} ]; then |
|
|
|
echo "Starting ThingsBoard ..." |
|
|
|
|
|
|
|
java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardServerApplication \ |
|
|
|
-Dspring.jpa.hibernate.ddl-auto=none \ |
|
|
|
-Dlogging.config=${CONF_FOLDER}/logback.xml \ |
|
|
|
org.springframework.boot.loader.PropertiesLauncher |
|
|
|
java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardServerApplication \ |
|
|
|
-Dspring.jpa.hibernate.ddl-auto=none \ |
|
|
|
-Dlogging.config=${CONF_FOLDER}/logback.xml \ |
|
|
|
org.springframework.boot.loader.PropertiesLauncher |
|
|
|
else |
|
|
|
echo "ERROR: ThingsBoard is not installed" |
|
|
|
fi |
|
|
|
|
|
|
|
stop-db.sh |