Skip to content

Keep Render Backend Active #492

Keep Render Backend Active

Keep Render Backend Active #492

# GitHub Action to keep Render backend active for CodeRush extension
# Pings the AtCoder contests endpoint to prevent cold starts
name: Keep Render Backend Active
on:
schedule:
# Every hour from 6 AM to 11 PM (UTC)
- cron: '0 6-23 * * *'
# Every 3 hours during night (12 AM, 3 AM UTC)
- cron: '0 0,3 * * *'
# Allow manual trigger for testing
workflow_dispatch:
jobs:
ping-backend:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Ping Render Backend
run: |
echo "🚀 Pinging Render backend to keep it active..."
# Ping the main server endpoint
echo "📡 Checking server status..."
curl -f -s -o /dev/null -w "Server Status: %{http_code} | Response Time: %{time_total}s\n" \
https://coderush-d1a0.onrender.com/ || echo "❌ Server ping failed"
# Ping the AtCoder contests endpoint specifically
echo "🎯 Fetching AtCoder contests..."
response=$(curl -f -s -w "HTTP Status: %{http_code} | Response Time: %{time_total}s" \
https://coderush-d1a0.onrender.com/atcoder-contests)
if [ $? -eq 0 ]; then
echo "✅ AtCoder endpoint successfully pinged"
echo "📊 Response details: $response"
# Extract and display contest count if response is JSON
contest_count=$(echo "$response" | jq '. | length' 2>/dev/null || echo "N/A")
echo "📈 Available contests: $contest_count"
else
echo "❌ AtCoder endpoint ping failed"
exit 1
fi
- name: Log ping result
run: |
echo "⏰ Ping completed at: $(date -u)"
echo "🌍 Current UTC time: $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
echo "🇮🇳 Current IST time: $(TZ='Asia/Kolkata' date '+%Y-%m-%d %H:%M:%S IST')"
- name: Notify on failure
if: failure()
run: |
echo "🚨 Backend ping failed! This might indicate:"
echo " • Render service is down"
echo " • Network connectivity issues"
echo " • Server configuration problems"
echo "🔧 Check Render dashboard and server logs for details"
# Optional: Check if backend is responding properly
health-check:
runs-on: ubuntu-latest
needs: ping-backend
steps:
- name: Comprehensive Health Check
run: |
echo "🏥 Running comprehensive health check..."
# Check server response time
response_time=$(curl -o /dev/null -s -w "%{time_total}" https://coderush-d1a0.onrender.com/)
echo "⚡ Server response time: ${response_time}s"
# Validate AtCoder endpoint returns valid JSON
echo "🔍 Validating AtCoder API response..."
curl -s https://coderush-d1a0.onrender.com/atcoder-contests | jq empty
if [ $? -eq 0 ]; then
echo "✅ Backend is healthy and returning valid data"
else
echo "⚠️ Backend response might be malformed"
fi
echo "📊 Health check completed successfully!"