Giter VIP home page Giter VIP logo

status-page's Introduction

status-page

Gem Version Build Status Dependency Status Coverage Status

Mountable status page for your Rails application, to check (DB, Cache, Sidekiq, Redis, etc.).

Mounting this gem will add a '/status' route to your application, which can be used for health monitoring the application and its various services. The method will return an appropriate HTTP status as well as a JSON array representing the state of each service.

Example

Install

# Gemfile
gem 'status-page'

Then run:

$ bundle install
# config/routes.rb
mount StatusPage::Engine, at: '/'

Supported service services

The following services are currently supported:

  • DB
  • Cache
  • Redis
  • Sidekiq
  • Resque

Configuration

Adding services

By default, only the database check is enabled. You can add more service services by explicitly enabling them via an initializer:

StatusPage.configure do
  # Cache check status result 10 seconds
  self.interval = 10
  # Use service
  self.use :database
  self.use :cache
  self.use :redis
  # Custom redis url
  self.use :redis, url: 'redis://you-redis-host:3306/1'
  self.use :sidekiq
end

Adding a custom service

It's also possible to add custom health check services suited for your needs (of course, it's highly appreciated and encouraged if you'd contribute useful services to the project).

In order to add a custom service, you'd need to:

  • Implement the StatusPage::Services::Base class and its check! method (a check is considered as failed if it raises an exception):
class CustomService < StatusPage::Services::Base
  def check!
    raise 'Oh oh!'
  end
end
  • Add its class to the config:
StatusPage.configure do
  self.add_custom_service(CustomProvider)
end

Adding a custom error callback

If you need to perform any additional error handling (for example, for additional error reporting), you can configure a custom error callback:

StatusPage.configure do
  self.error_callback = proc do |e|
    logger.error "Health check failed with: #{e.message}"

    Raven.capture_exception(e)
  end
end

Adding authentication credentials

By default, the /status endpoint is not authenticated and is available to any user. You can authenticate using HTTP Basic Auth by providing authentication credentials:

StatusPage.configure do
  self.basic_auth_credentials = {
    username: 'SECRET_NAME',
    password: 'Shhhhh!!!'
  }
end

License

The MIT License (MIT)

status-page's People

Contributors

huacnlee avatar joshdvir avatar lbeder avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.