73 lines
2.2 KiB
Bash
73 lines
2.2 KiB
Bash
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
|
|
PRIVATE_IP="${PRIVATE_IP:-192.168.0.5}"
|
|
ROOT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
COMPOSE="${ROOT_DIR}/pours/deployment/compose.yaml"
|
|
errors=0
|
|
|
|
wait_for() {
|
|
local label="$1"
|
|
local timeout_seconds="$2"
|
|
shift
|
|
shift
|
|
local deadline=$((SECONDS + timeout_seconds))
|
|
printf '%-34s' "$label"
|
|
until "$@" >/dev/null 2>&1; do
|
|
if ((SECONDS >= deadline)); then
|
|
echo "FAIL"
|
|
errors=$((errors + 1))
|
|
return 0
|
|
fi
|
|
sleep 5
|
|
done
|
|
echo "OK"
|
|
}
|
|
|
|
container_healthy() {
|
|
[[ "$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' "$1" 2>/dev/null)" == healthy ]]
|
|
}
|
|
|
|
one_shot_ok() {
|
|
local state
|
|
state="$(docker inspect --format '{{.State.Status}} {{.State.ExitCode}}' "$1" 2>/dev/null)" || return 1
|
|
[[ "$state" == "running 0" || "$state" == "exited 0" ]]
|
|
}
|
|
|
|
[[ -f "$COMPOSE" ]] || { echo "Не найден $COMPOSE" >&2; exit 1; }
|
|
echo "=== SigNoz: состояние ==="
|
|
docker compose -f "$COMPOSE" ps
|
|
echo
|
|
|
|
wait_for "PostgreSQL healthy" 300 container_healthy \
|
|
signoz-metastore-postgres-0
|
|
wait_for "ClickHouse Keeper healthy" 300 container_healthy \
|
|
signoz-telemetrykeeper-clickhousekeeper-0
|
|
wait_for "ClickHouse healthy" 300 container_healthy \
|
|
signoz-telemetrystore-clickhouse-0-0
|
|
wait_for "SigNoz healthy" 300 container_healthy \
|
|
signoz-signoz-0
|
|
wait_for "SigNoz API/UI" 300 curl -fsS --max-time 5 \
|
|
http://127.0.0.1:8080/api/v1/health
|
|
wait_for "OTLP gRPC TCP 4317" 300 timeout 3 bash -c \
|
|
"exec 3<>/dev/tcp/${PRIVATE_IP}/4317"
|
|
wait_for "OTLP HTTP 4318" 300 curl -fsS --max-time 5 \
|
|
-H "Content-Type: application/json" \
|
|
--data '{"resourceSpans":[]}' \
|
|
"http://${PRIVATE_IP}:4318/v1/traces"
|
|
wait_for "User scripts completed" 300 one_shot_ok \
|
|
signoz-telemetrystore-clickhouse-user-scripts
|
|
wait_for "Migrations running/completed" 300 one_shot_ok \
|
|
signoz-telemetrystore-migrator
|
|
|
|
echo
|
|
docker compose -f "$COMPOSE" ps -a
|
|
echo
|
|
ss -lntp "( sport = :8080 or sport = :4317 or sport = :4318 )"
|
|
if ((errors)); then
|
|
echo "Проверка завершилась с ошибками: $errors" >&2
|
|
echo "Логи: docker compose -f '$COMPOSE' logs --tail=200" >&2
|
|
exit 1
|
|
fi
|
|
echo "SigNoz готов."
|