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)


15
16
17
18
19
# File 'app/controllers/standard_health/health_controller.rb', line 15

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