Update for check component start status when init

This commit is contained in:
Tianyong Qiu 2025-02-12 21:49:33 +08:00
parent 137c9936b0
commit b56dc31882

View File

@ -793,6 +793,11 @@ devbox_init_command() {
local components=("devsvc" "notification" "content" "central_storage" "authentication")
local start_components=()
# if use online components, check if any component image repo is specified
if [[ "$USE_LOCAL_COMPONENT" == false ]]; then
is_pull_all_components=false
fi
echo "==> Checking parameters..."
for component in "${components[@]}"; do
if [[ -n "$(get_arg "--${component}-image-repo")" ]]; then
@ -832,6 +837,7 @@ devbox_init_command() {
fi
done
# If is_pull_all_components is true, then pull all components
if [[ "$is_pull_all_components" == true ]]; then
start_components=("${components[@]}")
@ -1071,11 +1077,8 @@ else
echo ' ===> Using online components for Freeleaps services.'
echo '============================================'
# Start Gitea, MongoDB, RabbitMQ containers
local_components_docker_compose_output=$(docker-compose -f docker-compose.dev.arm64.new.yaml up -d mongodb rabbitmq)
if [[ -z "$local_components_docker_compose_output" ]]; then
echo "ERROR: Failed to start MongoDB, RabbitMQ containers."
exit 1
fi
docker-compose -f docker-compose.dev.arm64.new.yaml up -d mongodb rabbitmq
echo "===> start components is $start_components"
# Save MongoDB and RabbitMQ container ids to .mongodb-instance and .rabbitmq-instance
mongo_container_id=$(docker ps -a --format '{{.Names}}' | grep "^freeleaps2-mongodb\$")
@ -1085,6 +1088,15 @@ else
echo "$rabbitmq_container_id" > "$WORKING_HOME/.rabbitmq-instance"
fi
# Check all components are started
for component in "${start_components[@]}"; do
if [[ -z "$(docker ps -a --format '{{.Names}}' | grep "^$component\$")" ]]; then
echo "ERROR: Failed to start $component container."
exit 1
fi
done
# Save $USE_LOCAL_COMPONENT false/true to $WORKING_HOME/.use-local-component
echo "$USE_LOCAL_COMPONENT" > "$WORKING_HOME/.use-local-component"