Skip to content

Production Health Check #7283

Production Health Check

Production Health Check #7283

Workflow file for this run

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)"