• Stars
    star
    158
  • Rank 237,131 (Top 5 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple Rack middleware for checking application health.

Pinglish

A simple Rack middleware for checking application health. Pinglish exposes a /_ping resource via HTTP GET, returning JSON that conforms to the spec below.

The Spec

  1. The application must respond to GET /_ping as an HTTP request.

  2. The request handler should check the health of all services the application depends on, answering questions like, "Can I query against my MySQL database," "Can I create/read keys in Redis," or "How many docs are in my ElasticSearch index?"

  3. The response must return within 29 seconds. This is one second less than the default timeout for many monitoring services.

  4. The response must return an HTTP 200 OK status code if all health checks pass.

  5. The response must return an HTTP 503 SERVICE UNAVAILABLE status code if any health checks fail.

  6. The response must be of Content-Type application/json; charset=UTF-8.

  7. The response must be valid JSON no matter what, even if JSON serialization or other fundamental code fails.

  8. The response must contain a "status" key set either to "ok" or "failures".

  9. The response must contain a "now" key set to the current server's time in seconds since epoch as a string.

  10. If the "status" key is set to "failures", the response may contain a "failures" key set to an Array of string names representing failed checks.

  11. If the "status" key is set to "failures", the response may contain a "timeouts" key set to an Array of string names representing checks that exceeded an implementation-specific individual timeout.

  12. The response body may contain any other top-level keys to supply additional data about services the application consumes, but all values must be strings, arrays of strings, or hashes where both keys and values are strings.

An Example Response

{

  // These two keys will always exist.

  "now": "1359055102",
  "status": "failures",

  // This key may only exist when a named check has failed.

  "failures": ["db"],

  // This key may only exist when a named check exceeds its timeout.

  "timeouts": ["really-long-check"],

  // Keys like this may exist to provide extra information about
  // healthy services, like the number of objects in an S3 bucket.

  "s3": "127"
}

The Middleware

require "pinglish"

use Pinglish do |ping|

  # A single unnamed check is the simplest possible way to use
  # Pinglish, and you'll probably never want combine it with other
  # named checks. An unnamed check contributes to overall success or
  # failure, but never adds additional data to the response.

  ping.check do
    App.healthy?
  end

  # A named check like this can provide useful summary information
  # when it succeeds. In this case, a top-level "db" key will appear
  # in the response containing the number of items in the database. If
  # a check returns nil, no key will be added to the response.

  ping.check :db do
    App.db.items.size
  end

  # By default, checks time out after one second. You can override
  # this with the :timeout option, but be aware that no combination of
  # checks is ever allowed to exceed the overall 29 second limit.

  ping.check :long, :timeout => 5 do
    App.dawdle
  end

  # Signal check failure by raising an exception. Any exception will do.
  ping.check :fails do
    raise "Everything's ruined."
  end

  # Additionally, any check that returns false is counted as a failure.
  ping.check :false_fails do
    false
  end
end

More Repositories

1

johnson

Johnson wraps JavaScript in a loving Ruby embrace.
Ruby
466
star
2

isolate

Gem segregation.
Ruby
249
star
3

pastejour

Broadcast standard out.
Ruby
66
star
4

vlad-git

Git support for Vlad.
Ruby
65
star
5

intercession

Your session loves you.
Ruby
50
star
6

watchable

A simple event/notification mixin for Ruby.
Ruby
40
star
7

herogit

DON'T YOU KNOW WHO I AM?!
Ruby
34
star
8

hoe-git

A Hoe plugin for tighter Git integration.
Ruby
25
star
9

stateful

Give an object or class stateful behavior.
Ruby
22
star
10

gchart

Exposes the Google Chart API via a friendly Ruby interface.
Ruby
22
star
11

dr-nic-magic-awesome

Magically fix your projects overnight!
18
star
12

dotfiles

Bash, Emacs, and various other configs.
Shell
15
star
13

hooky

Write Git hooks in your Rakefile.
Ruby
14
star
14

house-styles

A collection of coding style guides. Fork and add your own!
Ruby
14
star
15

hoe-debugging

A Hoe plugin to help you fix your broken codes.
Ruby
13
star
16

configlet

Configuration mismanagement.
Ruby
12
star
17

lunr

A read-only model layer for Sunspot and Solr.
Ruby
12
star
18

lather

Lather rinses and repeats.
Ruby
9
star
19

castigate

Abuse every revision of a Ruby/Rails project.
Ruby
8
star
20

insinuate

Broken. Two bits of delicious information.
Ruby
7
star
21

basis

YAPGT.
Ruby
7
star
22

sploit

This is so dumb.
Ruby
7
star
23

modelizer

Sometimes fixtures just ain't enough.
Ruby
6
star
24

backpack-journal

CLI for 37signals' Backpack Journal. Up for adoption!
Ruby
6
star
25

deeby

Tasks to switch your database configuration for a single Rake run.
Ruby
6
star
26

hoe-plugin-examples

Simple examples of how to write Hoe plugins.
Ruby
5
star
27

rubygems-future

Experiments. Don't hold your breath.
Ruby
5
star
28

jbarnette.github.com

My website.
Ruby
4
star
29

spidermonkey

Mozilla SpiderMonkey mirror and patches for Johnson.
JavaScript
4
star
30

between

Move data between rich models and simple structures.
Ruby
3
star
31

hoe-rubygems

A Hoe plugin with some additional RubyGems support.
Ruby
3
star
32

simplifier

Translate Ruby object graphs to simpler types.
Ruby
3
star
33

osx-multitouch

Broken. Trackpad multitouch in Ruby.
Ruby
3
star
34

hoe-doofus

A Hoe plugin to keep me from making broken releases.
Ruby
3
star
35

rack-goggles

Rack middleware for JSON API visibility.
JavaScript
3
star
36

onesie

One-page app helper for Rack stacks.
Ruby
2
star
37

contexts

Combine multiple Go contexts
Go
2
star
38

rake-secrets

Helpful tasks for storing sensitive stuff.
Ruby
2
star
39

logfmt

JSONL pretty-printer
Go
2
star
40

botany

A git branch switcher for Atom.
CoffeeScript
1
star
41

fortress

Multiple CI Joes working together.
Ruby
1
star
42

docker-oauth2-proxy

1
star
43

basis-gem-hoe

Nothing to see here.
Ruby
1
star
44

basis-rails-minimal

Ruby
1
star