Class: GoodJob::ProbeServer::ClusterHealthcheckMiddleware
- Inherits:
-
Object
- Object
- GoodJob::ProbeServer::ClusterHealthcheckMiddleware
- Defined in:
- lib/good_job/probe_server/cluster_healthcheck_middleware.rb
Overview
Rack middleware that answers health checks for a Supervisor in
cluster mode. Unlike HealthcheckMiddleware, which inspects the current
process's schedulers and notifiers, this reports on the cluster as a whole:
the supervisor process runs no scheduler, so started is derived from
whether all configured subprocesses are currently running, and connected
from whether each subprocess has recently reported itself ready (its
scheduler running and notifier connected) over its readiness heartbeat.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, supervisor) ⇒ ClusterHealthcheckMiddleware
constructor
A new instance of ClusterHealthcheckMiddleware.
Constructor Details
#initialize(app, supervisor) ⇒ ClusterHealthcheckMiddleware
Returns a new instance of ClusterHealthcheckMiddleware.
14 15 16 17 |
# File 'lib/good_job/probe_server/cluster_healthcheck_middleware.rb', line 14 def initialize(app, supervisor) @app = app @supervisor = supervisor end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/good_job/probe_server/cluster_healthcheck_middleware.rb', line 19 def call(env) case Rack::Request.new(env).path when '/', '/status' [200, {}, ["OK"]] when '/status/started' @supervisor.started? ? [200, {}, ["Started"]] : [503, {}, ["Not started"]] when '/status/connected' @supervisor.connected? ? [200, {}, ["Connected"]] : [503, {}, ["Not connected"]] else @app.call(env) end end |