[HLCC-ICE-000001][ZY-CONTRIB-20260723-001] feat: 以来光者贡献链启用冰朔第五域个人子频道
This commit is contained in:
commit
5615453e4e
660 changed files with 122355 additions and 0 deletions
29
server-tools/light-lake-node-bootstrap/health-check.sh
Executable file
29
server-tools/light-lake-node-bootstrap/health-check.sh
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
NODE_FILE=${NODE_FILE:-/etc/guanghu/node.json}
|
||||
REPO_DIR=${REPO_DIR:-/opt/guanghu/fifth-domain}
|
||||
HEALTH_URL=${HEALTH_URL:-http://127.0.0.1:3911/health}
|
||||
HEALTH_RETRIES=${HEALTH_RETRIES:-20}
|
||||
HEALTH_RETRY_DELAY=${HEALTH_RETRY_DELAY:-1}
|
||||
|
||||
node_id=$(jq -r '.node_id' "$NODE_FILE")
|
||||
service_state=$(systemctl is-active guanghu-gatekeeper.service)
|
||||
health=
|
||||
for ((attempt = 1; attempt <= HEALTH_RETRIES; attempt++)); do
|
||||
if health=$(curl -fsS "$HEALTH_URL" 2>/dev/null); then
|
||||
break
|
||||
fi
|
||||
sleep "$HEALTH_RETRY_DELAY"
|
||||
done
|
||||
[[ -n $health ]] || { echo "Gatekeeper health endpoint unavailable after ${HEALTH_RETRIES} attempts" >&2; exit 1; }
|
||||
commit=$(git -C "$REPO_DIR" rev-parse --short HEAD)
|
||||
disk_used=$(df --output=pcent / | tail -1 | tr -d ' ')
|
||||
|
||||
jq -n \
|
||||
--arg node_id "$node_id" \
|
||||
--arg service "$service_state" \
|
||||
--arg commit "$commit" \
|
||||
--arg disk_used "$disk_used" \
|
||||
--argjson gatekeeper "$health" \
|
||||
'{ok:true,node_id:$node_id,service:$service,repo_commit:$commit,disk_used:$disk_used,gatekeeper:$gatekeeper}'
|
||||
Loading…
Reference in a new issue