No release in over a year
Health check routes and functions
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Katalyst::Healthcheck

Rails application and background task health monitoring.

Installation

Add this line to your application's Gemfile:

gem 'katalyst-healthcheck'

And then execute:

$ bundle

Or install it yourself as:

$ gem install katalyst-healthcheck

Usage

Configuration:

Redis URL will automatically be set from Rails configuration, but can be configured manually in an initializer, e.g.

Katalyst::Healthcheck.configure do |config|
  config.store.redis.options.url = "redis://hostname:port"
end

Add to routes:

get '/healthcheck', to: Katalyst::Healthcheck::Route.static(200, "OK")
get '/healthcheck/status', to: Katalyst::Healthcheck::Route.from_tasks
get '/healthcheck/dashboard', to: Katalyst::Healthcheck::Route.from_tasks(detail: true)

With the above configuration, the following routes will be available:

/healthcheck

A basic check that tests that the rails application is up and running.

/healthcheck/status

Tests that all application background tasks are running as expected.

All background tasks to be monitored must register successful completion of their work using the Katalyst::Healthcheck::Monitored concern's healthy! and unhealthy methods, e.g.

include Katalyst::Healthcheck::Monitored

define_healthcheck_task :my_task, "My task description", interval: 1.day

def do_task
  ... task code here ...
  healthy!(:my_task)
rescue Exception => e
  unhealthy!(:my_task, e.message)
end

Call healthy! at successful completion of a task to mark the task as healthy. Optionally, calling unhealthy! immediately marks that task as unhealthy. If a task is not marked as healthy! within a predefined interval, that task is considered unhealthy.

License

The gem is available as open source under the terms of the MIT License.