jnewland / pulse

Pulse adds an action to your rails app that can be used for external health checking

This URL has Read+Write access

jnewland (author)
Mon Oct 20 08:02:20 -0700 2008
commit  a0e66d531f71f5c9021ef57f1db750576b0992df
tree    01ddd2c8b045d8b8804e310ac52a42dea271c165
parent  3a26779d28eb5395b31bf34a67158af73f9ea30e parent  865370a17b8af5cafe17f14330da6ec9e5b25dd0
pulse /
name age message
file .gitignore Fri Oct 03 14:11:03 -0700 2008 docs and a gemspec [jnewland]
file README.textile Mon Oct 06 11:08:28 -0700 2008 clarify example haproxy configuration [jnewland]
file Rakefile Fri Oct 03 14:10:49 -0700 2008 rakefile to run the specs [jnewland]
file init.rb Fri Oct 03 14:10:29 -0700 2008 add in DB support, fix loading so this can be i... [jnewland]
directory lib/ Loading commit data...
file pulse.gemspec Mon Oct 20 08:02:09 -0700 2008 fixup gemspec [jnewland]
directory spec/ Fri Oct 03 14:09:34 -0700 2008 ditch tests, add specs [jnewland]
README.textile

Pulse

Pulse adds an action to your rails project that can be used for external health checking. The most common use is by a http proxy such as haproxy or a monitoring tool such as god.

Authors

Requirements

  • Rails
  • MySQL, Postgres, or Oracle. sqlite not supported, sorry.

Installation

In your config/environment.rb:

  
    config.gem 'jnewland-pulse', :lib => 'pulse', :source => 'http://gems.github.com'
  

Install the gem:

  
    cd RAILS_ROOT
    rake gems:install
  

Finally, add a route to config/routes.rb:

  
    map.pulse 'pulse'
  

This configures pulse to work at the ‘pulse’ URL. If you would rather use a different URL:

  
    map.pulse 'some/other/url'
  

haproxy configuration

haproxy can be configured to use the /pulse url for its health checking. Just add:

  
    option httpchk GET /pulse
  
  
    listen rails :9000
      server rails-1 localhost:8000 maxconn 1 check inter 20000 fall 1
      server rails-2 localhost:8001 maxconn 1 check inter 20000 fall 1
      ...
  

god configuration

You are using god to watch your mongrels, right?

In your mongrel watch, add the following restart condition:

  
    w.restart_if do |restart|
      ...
      restart.condition(:http_response_code) do |c|
        c.code_is_not = 200
        c.host = 'localhost'
        c.path = '/pulse'
        c.port = 8000
        c.timeout = 5.seconds
        c.interval = 20.seconds
      end
    end
  

Also make sure to give your mongrels a nice grace period.

  
    ...
    w.start_grace = 90.seconds
    w.restart_grace = 90.seconds
    ...
  

For a complete god configuration example, check out my god_examples project and the included sample rails god config.

License

Released under Ruby’s license