Active service health checks

Replace static delays with active health checks in CI/CD workflows to ensure service readiness. Instead of using fixed sleep times, implement polling mechanisms that verify service health endpoints. This improves workflow reliability and reduces false negatives.

copy reviewer prompt

Prompt

Reviewer Prompt

Replace static delays with active health checks in CI/CD workflows to ensure service readiness. Instead of using fixed sleep times, implement polling mechanisms that verify service health endpoints. This improves workflow reliability and reduces false negatives.

Example implementation:

- name: Wait for service readiness
  run: |
    for i in {1..18}; do               # 18 ร— 5 s = 90 s timeout
      if curl -fs http://localhost/health >/dev/null; then
        break
      fi
      echo "๐Ÿ•’ Waiting for service to become healthy... ($i)"
      sleep 5
    done
    curl -fs http://localhost/health >/dev/null || {
      echo "โŒ Service did not become healthy in time" >&2
      exit 1
    }

This approach:

  • Actively verifies service availability
  • Provides clear feedback during waiting period
  • Fails fast if service is unhealthy
  • Accommodates varying startup times
  • Includes proper error handling

Source discussions