Skip to content

otto-de-legacy/sinatra-health-check

Repository files navigation

sinatra-health-check

Gem Version travis-ci Code Climate Test Coverage

This tiny gem adds graceful stop to your sinatra application.

Stopping apps gracefully allows your running requests to finish before killing the app. It gives some time to configure load balancers before shutting things down.

Usage

Initialize the health check:

require 'sinatra-health-check'
@checker = SinatraHealthCheck::Checker.new

Optionally add subsystems to the Checker:

# mysubsystem responds to :status with a SinatraHealthCheck::Status object
@checker.systems[:mysubsystem] = mysubsystem

Then use it inside your health check route:

get "/internal/health" do
  if @checker.healthy?
    "healthy"
  else
    status 503
    "unhealthy"
  end
end

Deliver a status document showing overall health/status and status of all subsystems:

get "/internal/status" do
  headers 'content-type' => 'application/json'
  @checker.status.to_json
end

Contributing

It's fast and simple: fork + PR.

License

This program is licensed under the MIT license. See LICENSE for details.

About

This tiny gem adds graceful stop to your sinatra application.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages