No commit activity in last 3 years
No release in over 3 years
A simple health check for sinatra applications
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

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.