Add healthcheck for dependent containers (#308)

This commit is contained in:
Evgeniy Antonyuk 2024-08-14 12:43:06 +03:00 committed by GitHub
parent 07cce071d2
commit 3a6a9ac574
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 41 additions and 4 deletions

View File

@ -1383,7 +1383,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
@ -1395,7 +1395,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

View File

@ -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:

View File

@ -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

View File

@ -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:

View File

@ -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}

View File

@ -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:

View File

@ -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}

View File

@ -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}