Update source/agent-remote/_allservicesstatus.sh
This commit is contained in:
@@ -68,16 +68,30 @@ function run_command() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# run the command in a subshell to prevent environment changes
|
# run the command in a subshell to prevent environment changes
|
||||||
|
# This subshell creates a completely isolated environment for each service
|
||||||
CURRENT_OUTPUT=$(
|
CURRENT_OUTPUT=$(
|
||||||
|
# Start with a clean environment for each service
|
||||||
set -a
|
set -a
|
||||||
|
|
||||||
load_dotenv "${service_path}/config/service.env"
|
# First set the core variables that other env vars might reference
|
||||||
load_dotenv "${service_path}/config/.template_info.env"
|
export SERVER="${SERVER}"
|
||||||
|
export SERVICE_NAME="" # Will be set from .template_info.env
|
||||||
# update the main variables.
|
export SERVICE="" # Will be set after loading SERVICE_NAME
|
||||||
export CONFIG_PATH="${service_path}/config"
|
|
||||||
export SERVICE="${SERVICE_NAME}"
|
|
||||||
export DOCKER_CLI_HINTS=false
|
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"
|
||||||
|
|
||||||
|
# Now set SERVICE from SERVICE_NAME (critical for CONTAINER_NAME expansion)
|
||||||
|
export SERVICE="${SERVICE_NAME}"
|
||||||
|
|
||||||
|
# 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
|
set +a
|
||||||
|
|
||||||
@@ -122,11 +136,21 @@ for SERVICE_NAME in ${SERVICE_NAMES}; do
|
|||||||
if ! command_exists "${SERVICE_PATH}" "status"; then
|
if ! command_exists "${SERVICE_PATH}" "status"; then
|
||||||
SERVICE_HEALTH="unknown"
|
SERVICE_HEALTH="unknown"
|
||||||
else
|
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"
|
run_command "${SERVICE_PATH}" "status" "false"
|
||||||
if [ "${CURRENT_EXIT_CODE}" -eq 0 ]; then
|
if [ "${CURRENT_EXIT_CODE}" -eq 0 ]; then
|
||||||
SERVICE_HEALTH="healthy"
|
SERVICE_HEALTH="healthy"
|
||||||
else
|
else
|
||||||
SERVICE_HEALTH="unhealthy"
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user