sinatra-health-check
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.newOptionally add subsystems to the Checker:
# mysubsystem responds to :status with a SinatraHealthCheck::Status object
@checker.systems[:mysubsystem] = mysubsystemThen use it inside your health check route:
get "/internal/health" do
if @checker.healthy?
"healthy"
else
status 503
"unhealthy"
end
endDeliver 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
endContributing
It's fast and simple: fork + PR.
License
This program is licensed under the MIT license. See LICENSE for details.