Skip to content

Keep Backend Alive #1640

Keep Backend Alive

Keep Backend Alive #1640

Workflow file for this run

name: Keep Backend Alive
# Pings the Render backend every 5 minutes so the free-tier instance
# does not spin down due to inactivity (Render sleeps after ~15 min).
#
# Setup: add BACKEND_URL as a GitHub Actions variable in the repo:
# Settings → Secrets and variables → Actions → Variables → New variable
# Name: BACKEND_URL
# Value: https://stellar-explain-core.onrender.com (your Render URL)
on:
schedule:
- cron: "*/5 * * * *"
workflow_dispatch: # allow manual trigger from Actions tab
jobs:
ping:
name: Ping /health
runs-on: ubuntu-latest
steps:
- name: Ping backend health endpoint
run: |
echo "Pinging ${{ vars.BACKEND_URL }}/health ..."
# Render free-tier instances spin down after ~15 min idle and can take
# well over 10s to cold-start; give curl enough time to wait that out.
# curl already reports "000" via -w on any connection failure/timeout;
# `|| true` just stops that non-zero curl exit from aborting the script
# under `bash -e` before the warning below runs.
STATUS=$(curl -s -o /dev/null -w "%{http_code}" --max-time 60 "${{ vars.BACKEND_URL }}/health" || true)
echo "Response: $STATUS"
if [ "$STATUS" != "200" ]; then
echo "Warning: health check returned $STATUS"
else
echo "Backend is alive ✅"
fi