Files
getDomain/domain-api/deploy/multi-region/check_node_agent.sh
2026-04-18 23:52:51 +08:00

39 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SERVICE_NAME="${SERVICE_NAME:-domaincheck-node-agent}"
ENV_FILE="${ENV_FILE:-/etc/default/domaincheck-node-agent}"
echo "[1/4] environment file"
if [[ -f "${ENV_FILE}" ]]; then
echo "env file: ${ENV_FILE}"
else
echo "missing env file: ${ENV_FILE}"
fi
echo
echo "[2/4] key env summary"
if [[ -f "${ENV_FILE}" ]]; then
grep -E '^(OPS_CONTROL_PLANE_BASE_URL|NODE_CODE|NODE_REGION|NODE_ROLE|OPS_AGENT_POLL_INTERVAL_SECONDS|WORKER_SERVICE_NAME|API_SERVICE_NAME|SYNC_AGENT_SERVICE_NAME)=' "${ENV_FILE}" || true
else
echo "skip"
fi
echo
echo "[3/4] systemd status"
if systemctl list-unit-files "${SERVICE_NAME}.service" --no-pager >/dev/null 2>&1; then
systemctl is-enabled "${SERVICE_NAME}" || true
systemctl is-active "${SERVICE_NAME}" || true
else
echo "not-installed"
echo "inactive"
fi
echo
echo "[4/4] service detail"
if systemctl list-unit-files "${SERVICE_NAME}.service" --no-pager >/dev/null 2>&1; then
systemctl status "${SERVICE_NAME}" --no-pager -l | sed -n '1,25p' || true
else
echo "service not found: ${SERVICE_NAME}"
fi