Skip to content

Commit

Permalink
Add healthcheck for dependent containers
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-antonyuk committed Aug 8, 2024
1 parent 8dbf3dd commit 0b03395
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 4 deletions.
8 changes: 6 additions & 2 deletions install/OneClickInstall/install-Docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ install_product () {
reconfigure APP_URL_PORTAL "${APP_URL_PORTAL:-"http://${PACKAGE_SYSNAME}-router:8092"}"
reconfigure EXTERNAL_PORT ${EXTERNAL_PORT}

if [[ -z ${MYSQL_HOST} ]] && [ "$INSTALL_MYSQL_SERVER" == "true" ]; then
if [[ -z ${MYSQL_HOST} ]] && [ "$INSTALL_MYSQL_SERVER" == "true" ] && [[ -n $(docker ps -q --filter "name=${PACKAGE_SYSNAME}-mysql-server") ]]; then
echo -n "Waiting for MySQL container to become healthy..."
(timeout 30 bash -c "while ! docker inspect --format '{{json .State.Health.Status }}' ${PACKAGE_SYSNAME}-mysql-server | grep -q 'healthy'; do sleep 1; done") && echo "OK" || (echo "FAILED")
fi
Expand All @@ -1391,7 +1391,11 @@ install_product () {
offline_check_docker_image ${BASE_DIR}/healthchecks.yml

docker-compose -f $BASE_DIR/migration-runner.yml up -d
echo -n "Waiting for database migration to complete..." && docker wait ${PACKAGE_SYSNAME}-migration-runner && echo "OK"
if [[ -n $(docker ps -q --filter "name=${PACKAGE_SYSNAME}-migration-runner") ]]; then
echo -n "Waiting for database migration to complete..."
timeout 30 bash -c "while [ $(docker wait ${PACKAGE_SYSNAME}-migration-runner) -ne 0 ]; do sleep 1; done;" && echo "OK" || echo "FAILED"
fi

docker-compose -f $BASE_DIR/${PRODUCT}.yml up -d
docker-compose -f ${PROXY_YML} up -d
docker-compose -f $BASE_DIR/notify.yml up -d
Expand Down
6 changes: 6 additions & 0 deletions install/docker/dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ services:
- "SERVER_BASEPATH=/dashboards"
expose:
- "5601"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5601/api/status"]
interval: 10s
retries: 3
start_period: 10s
timeout: 10s

networks:
default:
Expand Down
3 changes: 2 additions & 1 deletion install/docker/db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ services:
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping --silent"]
test: ["CMD", "mysql", "-u", "${MYSQL_USER}", "--password=${MYSQL_PASSWORD}", "-e", ";"]
interval: 10s
timeout: 5s
start_period: 10s
retries: 3
volumes:
- mysql_data:/var/lib/mysql
Expand Down
6 changes: 6 additions & 0 deletions install/docker/ds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ services:
stdin_open: true
restart: always
stop_grace_period: 60s
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/info/info.json"]
interval: 30s
retries: 5
start_period: 60s
timeout: 10s

networks:
default:
Expand Down
2 changes: 1 addition & 1 deletion install/docker/migration-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
onlyoffice-migration-runner:
image: "${HUB}${REPO}/${DOCKER_IMAGE_PREFIX}-migration-runner:${DOCKER_TAG}"
container_name: ${MIGRATION_RUNNER_HOST}
restart: "no"
restart: "on-failure"
environment:
MYSQL_CONTAINER_NAME: ${MYSQL_CONTAINER_NAME}
MYSQL_HOST: ${MYSQL_HOST}
Expand Down
6 changes: 6 additions & 0 deletions install/docker/opensearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ services:
- "9600" # required for Performance Analyzer
ports:
- 127.0.0.1:9200:9200
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9200/_cluster/health?pretty"]
interval: 30s
retries: 3
start_period: 10s
timeout: 10s

networks:
default:
Expand Down
7 changes: 7 additions & 0 deletions install/docker/rabbitmq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ services:
expose:
- "5672"
- "80"
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "status"]
interval: 10s
retries: 3
start_period: 10s
timeout: 10s

networks:
default:
name: ${NETWORK_NAME}
Expand Down
7 changes: 7 additions & 0 deletions install/docker/redis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ services:
restart: always
expose:
- "6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
retries: 3
start_period: 10s
timeout: 10s

networks:
default:
name: ${NETWORK_NAME}
Expand Down

0 comments on commit 0b03395

Please sign in to comment.