made availability check the data container to ensure the correct order of starting the containers
This commit is contained in:
parent
d0e1228330
commit
e7b7e7dd1a
@ -34,6 +34,7 @@ services:
|
|||||||
- onlyoffice-redis
|
- onlyoffice-redis
|
||||||
- onlyoffice-rabbitmq
|
- onlyoffice-rabbitmq
|
||||||
environment:
|
environment:
|
||||||
|
- ONLYOFFICE_DATA_CONTAINER_HOST=onlyoffice-documentserver-data
|
||||||
- BALANCE=uri depth 3
|
- BALANCE=uri depth 3
|
||||||
- HTTP_CHECK=GET /healthcheck
|
- HTTP_CHECK=GET /healthcheck
|
||||||
- EXTRA_SETTINGS=http-check expect string true
|
- EXTRA_SETTINGS=http-check expect string true
|
||||||
|
@ -5,6 +5,8 @@ DATA_DIR="/var/www/onlyoffice/Data"
|
|||||||
LOG_DIR="/var/log/onlyoffice/documentserver"
|
LOG_DIR="/var/log/onlyoffice/documentserver"
|
||||||
|
|
||||||
ONLYOFFICE_DATA_CONTAINER=${ONLYOFFICE_DATA_CONTAINER:-false}
|
ONLYOFFICE_DATA_CONTAINER=${ONLYOFFICE_DATA_CONTAINER:-false}
|
||||||
|
ONLYOFFICE_DATA_CONTAINER_HOST=${ONLYOFFICE_DATA_CONTAINER_HOST:-localhost}
|
||||||
|
ONLYOFFICE_DATA_CONTAINER_PORT=80
|
||||||
|
|
||||||
SSL_CERTIFICATES_DIR="${DATA_DIR}/certs"
|
SSL_CERTIFICATES_DIR="${DATA_DIR}/certs"
|
||||||
SSL_CERTIFICATE_PATH=${SSL_CERTIFICATE_PATH:-${SSL_CERTIFICATES_DIR}/onlyoffice.crt}
|
SSL_CERTIFICATE_PATH=${SSL_CERTIFICATE_PATH:-${SSL_CERTIFICATES_DIR}/onlyoffice.crt}
|
||||||
@ -26,20 +28,24 @@ ONLYOFFICE_DEFAULT_CONFIG=/etc/onlyoffice/documentserver/default.json
|
|||||||
|
|
||||||
JSON="json -q -f ${ONLYOFFICE_DEFAULT_CONFIG}"
|
JSON="json -q -f ${ONLYOFFICE_DEFAULT_CONFIG}"
|
||||||
|
|
||||||
MYSQL_SERVER_HOST=${MYSQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)}
|
LOCAL_SERVICES=()
|
||||||
MYSQL_SERVER_PORT=${MYSQL_SERVER_PORT:-$(${JSON} services.CoAuthoring.sql.dbPort)}
|
|
||||||
MYSQL_SERVER_DB_NAME=${MYSQL_SERVER_DB_NAME:-$(${JSON} services.CoAuthoring.sql.dbName)}
|
|
||||||
MYSQL_SERVER_USER=${MYSQL_SERVER_USER:-$(${JSON} services.CoAuthoring.sql.dbUser)}
|
|
||||||
MYSQL_SERVER_PASS=${MYSQL_SERVER_PASS:-$(${JSON} services.CoAuthoring.sql.dbPass)}
|
|
||||||
|
|
||||||
RABBITMQ_SERVER_URL=$(${JSON} rabbitmq.url)
|
read_setting(){
|
||||||
RABBITMQ_SERVER_HOST=${RABBITMQ_SERVER_HOST:-${RABBITMQ_SERVER_URL#'amqp://'}}
|
MYSQL_SERVER_HOST=${MYSQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)}
|
||||||
RABBITMQ_SERVER_USER=${RABBITMQ_SERVER_USER:-$(${JSON} rabbitmq.login)}
|
MYSQL_SERVER_PORT=${MYSQL_SERVER_PORT:-$(${JSON} services.CoAuthoring.sql.dbPort)}
|
||||||
RABBITMQ_SERVER_PASS=${RABBITMQ_SERVER_PASS:-$(${JSON} rabbitmq.password)}
|
MYSQL_SERVER_DB_NAME=${MYSQL_SERVER_DB_NAME:-$(${JSON} services.CoAuthoring.sql.dbName)}
|
||||||
RABBITMQ_SERVER_PORT=${RABBITMQ_SERVER_PORT:-"5672"}
|
MYSQL_SERVER_USER=${MYSQL_SERVER_USER:-$(${JSON} services.CoAuthoring.sql.dbUser)}
|
||||||
|
MYSQL_SERVER_PASS=${MYSQL_SERVER_PASS:-$(${JSON} services.CoAuthoring.sql.dbPass)}
|
||||||
|
|
||||||
REDIS_SERVER_HOST=${REDIS_SERVER_HOST:-$(${JSON} services.CoAuthoring.redis.host)}
|
RABBITMQ_SERVER_URL=$(${JSON} rabbitmq.url)
|
||||||
REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-$(${JSON} services.CoAuthoring.redis.port)}
|
RABBITMQ_SERVER_HOST=${RABBITMQ_SERVER_HOST:-${RABBITMQ_SERVER_URL#'amqp://'}}
|
||||||
|
RABBITMQ_SERVER_USER=${RABBITMQ_SERVER_USER:-$(${JSON} rabbitmq.login)}
|
||||||
|
RABBITMQ_SERVER_PASS=${RABBITMQ_SERVER_PASS:-$(${JSON} rabbitmq.password)}
|
||||||
|
RABBITMQ_SERVER_PORT=${RABBITMQ_SERVER_PORT:-"5672"}
|
||||||
|
|
||||||
|
REDIS_SERVER_HOST=${REDIS_SERVER_HOST:-$(${JSON} services.CoAuthoring.redis.host)}
|
||||||
|
REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-$(${JSON} services.CoAuthoring.redis.port)}
|
||||||
|
}
|
||||||
|
|
||||||
waiting_for_connection(){
|
waiting_for_connection(){
|
||||||
until nc -z -w 3 "$1" "$2"; do
|
until nc -z -w 3 "$1" "$2"; do
|
||||||
@ -59,7 +65,9 @@ waiting_for_rabbitmq(){
|
|||||||
waiting_for_redis(){
|
waiting_for_redis(){
|
||||||
waiting_for_connection ${REDIS_SERVER_HOST} ${REDIS_SERVER_PORT}
|
waiting_for_connection ${REDIS_SERVER_HOST} ${REDIS_SERVER_PORT}
|
||||||
}
|
}
|
||||||
|
waiting_for_datacontainer(){
|
||||||
|
waiting_for_connection ${ONLYOFFICE_DATA_CONTAINER_HOST} ${ONLYOFFICE_DATA_CONTAINER_PORT}
|
||||||
|
}
|
||||||
update_mysql_settings(){
|
update_mysql_settings(){
|
||||||
${JSON} -I -e "this.services.CoAuthoring.sql.dbHost = '${MYSQL_SERVER_HOST}'"
|
${JSON} -I -e "this.services.CoAuthoring.sql.dbHost = '${MYSQL_SERVER_HOST}'"
|
||||||
${JSON} -I -e "this.services.CoAuthoring.sql.dbPort = '${MYSQL_SERVER_PORT}'"
|
${JSON} -I -e "this.services.CoAuthoring.sql.dbPort = '${MYSQL_SERVER_PORT}'"
|
||||||
@ -90,7 +98,7 @@ create_mysql_db(){
|
|||||||
${MYSQL} "${MYSQL_SERVER_DB_NAME}" < "${APP_DIR}/server/schema/createdb.sql"
|
${MYSQL} "${MYSQL_SERVER_DB_NAME}" < "${APP_DIR}/server/schema/createdb.sql"
|
||||||
}
|
}
|
||||||
|
|
||||||
start_nginx(){
|
update_nginx_settings(){
|
||||||
# Set up nginx
|
# Set up nginx
|
||||||
sed 's/^worker_processes.*/'"worker_processes ${NGINX_WORKER_PROCESSES};"'/' -i ${NGINX_CONFIG_PATH}
|
sed 's/^worker_processes.*/'"worker_processes ${NGINX_WORKER_PROCESSES};"'/' -i ${NGINX_CONFIG_PATH}
|
||||||
sed 's/worker_connections.*/'"worker_connections ${NGINX_WORKER_CONNECTIONS};"'/' -i ${NGINX_CONFIG_PATH}
|
sed 's/worker_connections.*/'"worker_connections ${NGINX_WORKER_CONNECTIONS};"'/' -i ${NGINX_CONFIG_PATH}
|
||||||
@ -127,19 +135,13 @@ start_nginx(){
|
|||||||
else
|
else
|
||||||
cp ${SYSCONF_TEMPLATES_DIR}/nginx/onlyoffice-documentserver.conf ${NGINX_ONLYOFFICE_PATH}
|
cp ${SYSCONF_TEMPLATES_DIR}/nginx/onlyoffice-documentserver.conf ${NGINX_ONLYOFFICE_PATH}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#start service
|
|
||||||
service nginx start
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_supervisor(){
|
update_supervisor_settings(){
|
||||||
# Copy modified supervisor start script
|
# Copy modified supervisor start script
|
||||||
cp ${SYSCONF_TEMPLATES_DIR}/supervisor/supervisor /etc/init.d/
|
cp ${SYSCONF_TEMPLATES_DIR}/supervisor/supervisor /etc/init.d/
|
||||||
# Copy modified supervisor config
|
# Copy modified supervisor config
|
||||||
cp ${SYSCONF_TEMPLATES_DIR}/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
|
cp ${SYSCONF_TEMPLATES_DIR}/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
|
||||||
|
|
||||||
#start service
|
|
||||||
service supervisor start
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# create base folders
|
# create base folders
|
||||||
@ -149,39 +151,58 @@ done
|
|||||||
|
|
||||||
mkdir -p ${LOG_DIR}-example
|
mkdir -p ${LOG_DIR}-example
|
||||||
|
|
||||||
if [ ${MYSQL_SERVER_HOST} != "localhost" ]; then
|
if [ ${ONLYOFFICE_DATA_CONTAINER_HOST} = "localhost" ]; then
|
||||||
|
|
||||||
|
read_setting
|
||||||
|
|
||||||
|
# update settings by env variables
|
||||||
|
if [ ${MYSQL_SERVER_HOST} != "localhost" ]; then
|
||||||
update_mysql_settings
|
update_mysql_settings
|
||||||
|
waiting_for_mysql
|
||||||
create_mysql_db
|
create_mysql_db
|
||||||
else
|
else
|
||||||
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
LOCAL_SERVICES+=("mysql")
|
||||||
service mysql start
|
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${RABBITMQ_SERVER_HOST} != "localhost" ]; then
|
if [ ${RABBITMQ_SERVER_HOST} != "localhost" ]; then
|
||||||
update_rabbitmq_setting
|
update_rabbitmq_setting
|
||||||
else
|
else
|
||||||
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
LOCAL_SERVICES+=("redis-server")
|
||||||
service redis-server start
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ${REDIS_SERVER_HOST} != "localhost" ]; then
|
||||||
|
update_redis_settings
|
||||||
|
else
|
||||||
|
LOCAL_SERVICES+=("rabbitmq-server")
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# no need to update settings just wait for remote data
|
||||||
|
waiting_for_datacontainer
|
||||||
|
|
||||||
|
# read settings after the data container in ready state
|
||||||
|
# to prevent get unconfigureted data
|
||||||
|
read_setting
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${REDIS_SERVER_HOST} != "localhost" ]; then
|
#start needed local services
|
||||||
update_redis_settings
|
for i in ${LOCAL_SERVICES[@]}; do
|
||||||
else
|
service $i start
|
||||||
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
done
|
||||||
service rabbitmq-server start
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
||||||
waiting_for_mysql
|
waiting_for_mysql
|
||||||
waiting_for_rabbitmq
|
waiting_for_rabbitmq
|
||||||
waiting_for_redis
|
waiting_for_redis
|
||||||
|
|
||||||
start_nginx
|
update_nginx_settings
|
||||||
start_supervisor
|
|
||||||
|
update_supervisor_settings
|
||||||
|
service supervisor start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# nginx used as a proxy, and as data container status service.
|
||||||
|
# it run in all cases.
|
||||||
|
service nginx start
|
||||||
|
|
||||||
# Regenerate the fonts list and the fonts thumbnails
|
# Regenerate the fonts list and the fonts thumbnails
|
||||||
documentserver-generate-allfonts.sh ${ONLYOFFICE_DATA_CONTAINER}
|
documentserver-generate-allfonts.sh ${ONLYOFFICE_DATA_CONTAINER}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user