Add health check for rabbitmq & mongodb startup

This commit is contained in:
Tianyong Qiu 2025-02-28 16:14:13 +08:00
parent 7715820214
commit 2d1323a40d
2 changed files with 48 additions and 11 deletions

View File

@ -860,6 +860,9 @@ echo "==> [INIT] Starting Freeleaps services... Use Local component $USE_LOCAL_C
export ARCH="$ARCH"
export WORKING_HOME="$WORKING_HOME"
# Check
if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then
@ -913,7 +916,22 @@ if [[ $USE_LOCAL_COMPONENT_VAL == true ]]; then
exit 1
fi
mkdir -p ${WORKING_HOME}/logs
mkdir -p ${WORKING_HOME}/logs/devsvc
mkdir -p ${WORKING_HOME}/logs/content
mkdir -p ${WORKING_HOME}/logs/central_storage
mkdir -p ${WORKING_HOME}/logs/authentication
mkdir -p ${WORKING_HOME}/logs/notification
mkdir -p ${WORKING_HOME}/logs/chat
# for each component create log directory
for component in "${start_components[@]}"; do
if [[ ! -d "${WORKING_HOME}/log/${component}" ]]; then
mkdir -p "${WORKING_HOME}/log/${component}"
fi
done
# Start Gitea, MongoDB, RabbitMQ and other components containers
echo "===> start Gitea, MongoDB, RabbitMQ and other components containers"

View File

@ -14,6 +14,12 @@ services:
- ${WORKING_HOME}/freeleaps2-gitea:/data:Z
networks:
- devbox_freeleaps2-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/"]
interval: 10s
timeout: 5s
retries: 5
start_period: 40s
mongodb:
# For apple chip, add: platform: linux/amd64
@ -29,6 +35,12 @@ services:
networks:
- devbox_freeleaps2-network
command: ["mongod", "--bind_ip_all"]
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
start_period: 40s
rabbitmq:
# For apple chip, add: platform: linux/amd64
@ -43,15 +55,23 @@ services:
- ${WORKING_HOME}/freeleaps2-rabbitmq-data:/var/lib/rabbitmq
networks:
- devbox_freeleaps2-network
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "status"]
interval: 10s
timeout: 5s
retries: 5
devsvc:
container_name: devsvc
image: freeleaps/devsvc:${DEVSVC_IMAGE_TAG:-latest-linux-arm64}
restart: always
depends_on:
- gitea
- mongodb
- rabbitmq
mongodb:
condition: service_healthy
rabbitmq:
condition: service_healthy
gitea:
condition: service_healthy
environment:
- APP_NAME=devsvc
- SERVICE_API_ACCESS_HOST=localhost
@ -85,7 +105,6 @@ services:
central_storage:
container_name: central_storage
image: freeleaps/central_storage:${CENTRAL_STORAGE_IMAGE_TAG:-latest-linux-arm64}
# profiles: [ prod, alpha, dev ]
platform: linux/${ARCH:-arm64}
restart: always
environment:
@ -117,7 +136,6 @@ services:
authentication:
container_name: authentication
image: freeleaps/authentication:${AUTHENTICATION_IMAGE_TAG:-latest-linux-arm64}
# profiles: [ prod, alpha, dev ]
platform: linux/${ARCH:-arm64}
restart: always
environment:
@ -151,7 +169,6 @@ services:
content:
container_name: content
image: freeleaps/content:${CONTENT_IMAGE_TAG:-latest-linux-arm64}
# profiles: [ prod, alpha, dev ]
platform: linux/${ARCH:-arm64}
restart: always
environment:
@ -182,11 +199,11 @@ services:
notification:
container_name: notification
image: freeleaps/notification:${NOTIFICATION_IMAGE_TAG:-latest-linux-arm64}
# profiles: [ prod, alpha, dev ]
platform: linux/${ARCH:-arm64}
restart: always
depends_on:
- rabbitmq
rabbitmq:
condition: service_healthy
environment:
- APP_NAME=notification
- SERVICE_API_ACCESS_HOST=localhost
@ -256,8 +273,10 @@ services:
dockerfile: ${WORKING_HOME}/freeleaps/apps/chat/Dockerfile
restart: always
depends_on:
- mongodb
- rabbitmq
mongodb:
condition: service_healthy
rabbitmq:
condition: service_healthy
ports:
- 8012:8012
environment: