@@ -12,31 +12,30 @@ jobs:
1212 timeout-minutes : 5
1313
1414 steps :
15- - name : Ping Backend (Render) with Retry
15+ - uses : actions/checkout@v3
16+
17+ - name : Set up Python
18+ uses : actions/setup-python@v3
19+ with :
20+ python-version : " 3.10"
21+
22+ - name : Install Playwright
23+ run : |
24+ python -m pip install --upgrade pip
25+ pip install playwright requests
26+ playwright install chromium
27+
28+ - name : Ping Backends (Render)
1629 run : |
17- echo "Pinging Render backend..."
18- for i in 1 2 3; do
19- HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 90 https://aio-health-backend.onrender.com/healthz)
20- echo "Attempt $i: HTTP $HTTP_CODE"
21- if [ "$HTTP_CODE" = "200" ]; then
22- echo "✅ Backend is UP"
23- exit 0
24- fi
25- echo "Waiting 30s for cold start..."
26- sleep 30
27- done
28- echo "⚠️ Backend may be slow to wake up"
29-
30- - name : Ping Frontend (Streamlit) with Retry
30+ echo "Pinging primary backend (Fastest/New)..."
31+ # Render wakes up if it receives any request. It might take 50s, so we give it a 30s timeout
32+ # Even if curl times out, the request reached Render and it will start waking up
33+ curl -s -o /dev/null -w "%{http_code}" --max-time 30 https://aio-health-backend-gdzi.onrender.com/healthz || echo "Primary ping sent"
34+
35+ echo "Pinging secondary backend (Fallback)..."
36+ curl -s -o /dev/null -w "%{http_code}" --max-time 30 https://aio-health-backend.onrender.com/healthz || echo "Secondary ping sent"
37+
38+ - name : Ping Frontend (Streamlit Headless)
3139 run : |
32- echo "Pinging Streamlit frontend..."
33- for i in 1 2; do
34- HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 60 https://ai-healthcare-system.streamlit.app/)
35- echo "Attempt $i: HTTP $HTTP_CODE"
36- if [ "$HTTP_CODE" = "200" ]; then
37- echo "✅ Frontend is UP"
38- exit 0
39- fi
40- sleep 15
41- done
42- echo "⚠️ Frontend may need manual wake-up"
40+ echo "Launching headless browser to check if Streamlit is asleep..."
41+ python scripts/keep_alive_frontend.py
0 commit comments