Production Health Check #7289
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Production Health Check | |
| on: | |
| schedule: | |
| # Run every 15 minutes | |
| - cron: '*/15 * * * *' | |
| workflow_dispatch: | |
| jobs: | |
| health-check: | |
| name: Monitor derail.me Health | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check main application | |
| run: | | |
| echo "π Checking https://derail.me..." | |
| # Check main site | |
| if curl -f -s --max-time 10 https://derail.me > /dev/null; then | |
| echo "β Main site is up" | |
| else | |
| echo "β Main site is down" | |
| exit 1 | |
| fi | |
| - name: Check API endpoints | |
| run: | | |
| echo "π Checking API endpoints..." | |
| # Check API health | |
| if curl -f -s --max-time 10 https://derail.me/api/cameras > /dev/null; then | |
| echo "β API is responding" | |
| else | |
| echo "β API is down" | |
| exit 1 | |
| fi | |
| - name: Check WebSocket streaming | |
| run: | | |
| echo "π Checking WebSocket availability..." | |
| # Basic WebSocket connectivity check | |
| if timeout 5 bash -c "</dev/tcp/derail.me/443"; then | |
| echo "β WebSocket port is accessible" | |
| else | |
| echo "β WebSocket connection failed" | |
| exit 1 | |
| fi | |
| - name: Check SSL certificate | |
| run: | | |
| echo "π Checking SSL certificate..." | |
| # Check SSL expiry (warn if less than 30 days) | |
| expiry_date=$(echo | openssl s_client -servername derail.me -connect derail.me:443 2>/dev/null | openssl x509 -noout -enddate | cut -d= -f2) | |
| expiry_epoch=$(date -d "$expiry_date" +%s) | |
| current_epoch=$(date +%s) | |
| days_until_expiry=$(( (expiry_epoch - current_epoch) / 86400 )) | |
| if [ $days_until_expiry -lt 30 ]; then | |
| echo "β οΈ SSL certificate expires in $days_until_expiry days" | |
| else | |
| echo "β SSL certificate is valid ($days_until_expiry days remaining)" | |
| fi | |
| - name: Performance check | |
| run: | | |
| echo "π Checking performance..." | |
| # Measure response time | |
| response_time=$(curl -o /dev/null -s -w "%{time_total}" https://derail.me) | |
| if (( $(echo "$response_time > 5.0" | bc -l) )); then | |
| echo "β οΈ Slow response time: ${response_time}s" | |
| else | |
| echo "β Good response time: ${response_time}s" | |
| fi | |
| - name: Database connectivity check | |
| run: | | |
| echo "π Checking database connectivity via API..." | |
| # Check if API can connect to database | |
| if curl -f -s --max-time 10 "https://derail.me/api/cameras" | grep -q "\[\]"; then | |
| echo "β Database is accessible" | |
| elif curl -f -s --max-time 10 "https://derail.me/api/cameras" | grep -q "id"; then | |
| echo "β Database is accessible with data" | |
| else | |
| echo "β Database connectivity issue" | |
| exit 1 | |
| fi | |
| - name: Notify if unhealthy | |
| if: failure() | |
| run: | | |
| echo "π¨ Health check failed for derail.me" | |
| # Send notification (webhook, email, etc.) | |
| if [ -n "${{ secrets.HEALTH_CHECK_WEBHOOK }}" ]; then | |
| curl -X POST "${{ secrets.HEALTH_CHECK_WEBHOOK }}" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "text": "π¨ ChittyPro Streamlink health check failed at derail.me", | |
| "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" | |
| }' | |
| fi | |
| - name: Log success | |
| if: success() | |
| run: | | |
| echo "β All health checks passed for derail.me" | |
| echo "Timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ)" |