Class: StandardHealth::HealthController

Inherits:
ApplicationController show all
Defined in:
app/controllers/standard_health/health_controller.rb

Instance Method Summary collapse

Instance Method Details

#aliveObject

Liveness probe. Returns 200 unconditionally — its only job is to confirm the Rails process is up and routing requests. Anything heavier belongs in /ready.



8
9
10
# File 'app/controllers/standard_health/health_controller.rb', line 8

def alive
  head :ok
end

#readyObject

Readiness probe. Runs every registered check and returns:

200 if the rolled-up status is :ok or :degraded
503 if any critical check failed (:unavailable)

Failure detail is REDACTED by default — see StandardHealth::Redactor. This endpoint is unauthenticated so probes need no credentials, and a raw driver error will happily tell an anonymous caller the database host, port and username. The full message goes to logs and Sentry instead. Status codes and every other field are unchanged.



21
22
23
24
25
26
# File 'app/controllers/standard_health/health_controller.rb', line 21

def ready
  result = StandardHealth::Aggregator.call
  http_status = result[:status] == :unavailable ? :service_unavailable : :ok
  render json: StandardHealth::Redactor.call(result, expose: expose_errors?),
         status: http_status
end