Files
Oleksandr Bezdieniezhnykh c7b297de83
ci/woodpecker/push/01-test Pipeline failed
ci/woodpecker/push/02-build-push unknown status
refactor: remove deploy.cmd and update Dockerfile for health checks
- Deleted the deploy.cmd script as it was no longer needed.
- Updated Dockerfile to include curl for health checks and added a non-root user for improved security.
- Modified health check command to use curl for better reliability.
- Adjusted docker-compose.test.yml to reflect changes in health check configuration.
- Cleaned up appsettings.json and removed unused configuration properties.
- Removed Resource entity and related requests from the codebase as part of the architectural shift.
- Updated documentation to reflect the removal of hardware binding and related endpoints.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 08:47:21 +03:00

50 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# scripts/health-check.sh — poll /health/ready until 200 or timeout. Used as
# the post-start gate by deploy.sh. Returns non-zero on any failure.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$SCRIPT_DIR/_lib.sh"
usage() {
cat <<'EOF'
Usage: ./scripts/health-check.sh [--help]
Reads from the environment:
DEPLOY_HOST_PORT port the container is published on (default 4000)
HEALTH_BASE_URL full URL override; defaults to http://127.0.0.1:$DEPLOY_HOST_PORT
HEALTH_TIMEOUT seconds total to wait (default 60)
HEALTH_INTERVAL seconds between attempts (default 2)
EOF
}
[[ "${1:-}" == "--help" || "${1:-}" == "-h" ]] && { usage; exit 0; }
require_cmd curl
PORT="${DEPLOY_HOST_PORT:-4000}"
BASE_URL="${HEALTH_BASE_URL:-http://127.0.0.1:$PORT}"
TIMEOUT="${HEALTH_TIMEOUT:-60}"
INTERVAL="${HEALTH_INTERVAL:-2}"
# Liveness first (cheap; fails only if the process is wedged).
log_info "Probing $BASE_URL/health/live"
if ! curl --fail --silent --show-error --max-time 3 "$BASE_URL/health/live" >/dev/null; then
die "/health/live did not return 200 — container is not responsive"
fi
log_info "Polling $BASE_URL/health/ready (timeout=${TIMEOUT}s, interval=${INTERVAL}s)"
DEADLINE=$(( $(date +%s) + TIMEOUT ))
ATTEMPT=0
while :; do
ATTEMPT=$((ATTEMPT + 1))
if BODY="$(curl --fail --silent --show-error --max-time 3 "$BASE_URL/health/ready" 2>/dev/null)"; then
log_info "/health/ready returned 200 on attempt $ATTEMPT: $BODY"
exit 0
fi
NOW=$(date +%s)
if (( NOW >= DEADLINE )); then
die "/health/ready did not return 200 within ${TIMEOUT}s (gave up after $ATTEMPT attempts)"
fi
sleep "$INTERVAL"
done