#!/bin/bash set -eo pipefail # WebsiteBox Health Check # Usage: ./scripts/healthcheck.sh echo "═══════════════════════════════════════════════════════════" echo " WebsiteBox Health Check" echo "═══════════════════════════════════════════════════════════" ALL_HEALTHY=true for service in nginx wordpress db; do container="websitebox-${service}" status=$(docker inspect --format='{{.State.Health.Status}}' "$container" 2>/dev/null || echo "not found") case "$status" in healthy) echo " [OK] ${service}: healthy" ;; unhealthy) echo " [FAIL] ${service}: unhealthy" ALL_HEALTHY=false ;; starting) echo " [WAIT] ${service}: starting..." ;; *) echo " [????] ${service}: ${status}" ALL_HEALTHY=false ;; esac done # Certbot doesn't have a healthcheck — just check if running certbot_state=$(docker inspect --format='{{.State.Status}}' websitebox-certbot 2>/dev/null || echo "not found") if [ "$certbot_state" = "running" ]; then echo " [OK] certbot: running" else echo " [WARN] certbot: ${certbot_state}" fi echo "" if [ "$ALL_HEALTHY" = true ]; then echo "All services are healthy." exit 0 else echo "Some services are not healthy. Check logs with:" echo " docker compose logs -f [service]" exit 1 fi