Update source/agent-remote/_allservicesstatus.sh
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 31s
Build-Test-Publish / build (linux/arm64) (push) Successful in 1m0s

This commit is contained in:
Your Name
2025-08-29 18:28:07 +12:00
parent e8efe73f4a
commit 04d240bbd2

View File

@@ -68,16 +68,30 @@ function run_command() {
fi
# run the command in a subshell to prevent environment changes
# This subshell creates a completely isolated environment for each service
CURRENT_OUTPUT=$(
# Start with a clean environment for each service
set -a
load_dotenv "${service_path}/config/service.env"
# First set the core variables that other env vars might reference
export SERVER="${SERVER}"
export SERVICE_NAME="" # Will be set from .template_info.env
export SERVICE="" # Will be set after loading SERVICE_NAME
export DOCKER_CLI_HINTS=false
export AGENT_PATH="${AGENT_PATH}"
export HOST_NAME="${HOST_NAME}"
# Load the template info first to get SERVICE_NAME and TEMPLATE
load_dotenv "${service_path}/config/.template_info.env"
# update the main variables.
export CONFIG_PATH="${service_path}/config"
# Now set SERVICE from SERVICE_NAME (critical for CONTAINER_NAME expansion)
export SERVICE="${SERVICE_NAME}"
export DOCKER_CLI_HINTS=false
# Set CONFIG_PATH before loading service.env as it might be referenced
export CONFIG_PATH="${service_path}/config"
# Now load service.env which can properly expand variables like CONTAINER_NAME=${SERVICE}
load_dotenv "${service_path}/config/service.env"
set +a
@@ -122,11 +136,21 @@ for SERVICE_NAME in ${SERVICE_NAMES}; do
if ! command_exists "${SERVICE_PATH}" "status"; then
SERVICE_HEALTH="unknown"
else
# Debug: capture output to see what's failing
run_command "${SERVICE_PATH}" "status" "true"
ERROR_OUTPUT="${CURRENT_OUTPUT}"
run_command "${SERVICE_PATH}" "status" "false"
if [ "${CURRENT_EXIT_CODE}" -eq 0 ]; then
SERVICE_HEALTH="healthy"
else
SERVICE_HEALTH="unhealthy"
# Debug: show error for simple-object-server services
if [ -f "${SERVICE_PATH}/config/.template_info.env" ]; then
source "${SERVICE_PATH}/config/.template_info.env"
if [ "${TEMPLATE}" = "simple-object-server" ]; then
>&2 echo "DEBUG ${SERVICE_NAME}: ${ERROR_OUTPUT}"
fi
fi
fi
fi