liveBook · Manning

Health check endpoint

As explained in GitHub Actions in Action: Continuous integration and delivery for DevOps

A health endpoint is an application endpoint that reports whether the application or a component is operational and ready to serve requests.

A health check endpoint reports whether an application is ready to receive traffic or is operating healthily. During deployment, it prevents a workflow from advancing before a newly installed version can serve requests safely. Common endpoints are `/health/ready`, which returns an OK or not-OK readiness status during startup, and `/health/lively`, which reports healthy, degraded, or unhealthy operation after deployment. section 9.3.4

Poll `/health/ready` after installation and inspect its JSON status. Continue only when the response signals `Healthy`; then run end-to-end tests or the next deployment stage. This makes readiness an explicit deployment gate rather than relying on a fixed delay. section 9.3.4 section 9.3.7

Listing 9.9 Checking the health status
      - name: ensure deployment is healthy before we test
        run: |
            HEALTH_ENDPOINT="https://${{stagingurl}}/health/ready"
            while true; do
              response=$(curl -s "$HEALTH_ENDPOINT")
              status=$(echo "$response" | jq -r '.status')
  
              if [[ "$status" == "Healthy" ]]; then
                echo "Health endpoint current status :" $status
                break
              fi
              echo "Waiting for health endpoint..."
              sleep 1
            done
        env: 
          homepage: ${{ needs.deploy.outputs.homepage }}

This shell step repeatedly calls a staging readiness URL with `curl`, extracts `.status` with `jq`, and waits one second between attempts until the application reports `Healthy`. section 9.3.4

Use the two endpoint roles differently in delivery workflows:

  • Gate startup progression with `/health/ready`; once it is healthy, begin validation such as end-to-end tests. section 9.3.4 section 9.3.7
  • Monitor `/health/lively` while gradually shifting traffic; abort and roll back if repeated responses show a degraded or unhealthy state. section 9.3.4
  • Combine health checks with environment gates when moving between deployment stages. section 9.4

Validate a staging slot before traffic routing

Deploy a release artifact to an Azure Web App staging slot, capture its URL, and poll `${homepage}/health/ready`. After it returns `Healthy`, run Playwright tests. Only then route 10% of traffic to the staging slot, observe behavior, increase traffic when appropriate, and swap slots when confidence is sufficient. section 9.3.7

How GitHub Actions in Action: Continuous integration and delivery for DevOps covers it

How deep it goes
Explains readiness and liveness roles and demonstrates polling JSON status, but defers application-side endpoint implementation.
Examples
Uses a curl-and-jq readiness loop and an Azure Web App staging-slot deployment validated with Playwright tests.
What it assumes
Assumes an application exposes health endpoints and a workflow can issue curl requests and parse JSON with jq.
What you can do after
Operate/configure it as a deployment gate by polling readiness before tests or traffic routing and monitoring liveness during rollout.
How it connects
Connects health checks to continuous delivery, end-to-end testing, red–green deployments, traffic routing, rollback, and metrics endpoints.

Also explained in

Compare how 5 books explain health check endpoint →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of GitHub Actions in Action: Continuous integration and delivery for DevOps. The section links point to the parts of the book it draws on.