Files
n8n-workflows/scripts/health-check.sh
Sahiix@1 3c0a92c460 ssd (#10)
* ok

ok

* Refactor README for better structure and readability

Updated README to improve formatting and clarity.

* Initial plan

* Initial plan

* Initial plan

* Initial plan

* Comprehensive deployment infrastructure implementation

Co-authored-by: sahiixx <221578902+sahiixx@users.noreply.github.com>

* Add comprehensive deployment infrastructure - Docker, K8s, CI/CD, scripts

Co-authored-by: sahiixx <221578902+sahiixx@users.noreply.github.com>

* Add files via upload

* Complete deployment implementation - tested and working production deployment

Co-authored-by: sahiixx <221578902+sahiixx@users.noreply.github.com>

* Revert "Implement comprehensive deployment infrastructure for n8n-workflows documentation system"

* Update docker-compose.prod.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update scripts/health-check.sh

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: dopeuni444 <sahiixofficial@wgmail.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-09-29 09:31:37 +04:00

103 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
# N8N Workflows Documentation - Health Check Script
# Usage: ./scripts/health-check.sh [endpoint]
set -euo pipefail
ENDPOINT="${1:-http://localhost:8000}"
MAX_ATTEMPTS=5
TIMEOUT=10
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log() {
echo -e "${BLUE}[$(date '+%Y-%m-%d %H:%M:%S')]${NC} $1"
}
warn() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
error() {
echo -e "${RED}[ERROR]${NC} $1"
}
success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
# Check if curl is available
if ! command -v curl &> /dev/null; then
error "curl is required but not installed"
exit 1
fi
log "Starting health check for $ENDPOINT"
# Test basic connectivity
for attempt in $(seq 1 $MAX_ATTEMPTS); do
log "Health check attempt $attempt/$MAX_ATTEMPTS"
# Test API stats endpoint
if response=$(curl -s -w "%{http_code}" -o /tmp/health_response --connect-timeout $TIMEOUT "$ENDPOINT/api/stats" 2>/dev/null); then
http_code=$(echo "$response" | tail -c 4 | head -c 3)
if [[ "$http_code" == "200" ]]; then
success "API is responding (HTTP $http_code)"
# Parse and display stats
if command -v jq &> /dev/null; then
stats=$(cat /tmp/health_response)
total=$(echo "$stats" | jq -r '.total // "N/A"')
active=$(echo "$stats" | jq -r '.active // "N/A"')
integrations=$(echo "$stats" | jq -r '.unique_integrations // "N/A"')
log "Database status:"
log " - Total workflows: $total"
log " - Active workflows: $active"
log " - Unique integrations: $integrations"
fi
# Test main page
if curl -s -f --connect-timeout $TIMEOUT "$ENDPOINT" > /dev/null; then
success "Main page is accessible"
else
warn "Main page is not accessible"
fi
# Test API documentation
if curl -s -f --connect-timeout $TIMEOUT "$ENDPOINT/docs" > /dev/null; then
success "API documentation is accessible"
else
warn "API documentation is not accessible"
fi
# Clean up
rm -f /tmp/health_response
success "All health checks passed!"
exit 0
else
warn "API returned HTTP $http_code"
fi
else
warn "Failed to connect to $ENDPOINT"
fi
if [[ $attempt -lt $MAX_ATTEMPTS ]]; then
log "Waiting 5 seconds before retry..."
sleep 5
fi
done
# Clean up
rm -f /tmp/health_response
error "Health check failed after $MAX_ATTEMPTS attempts"
exit 1