Blog Post RSS ?

Blogs » Ruby on Rails » Roll your own dispatch reaper script
 

Roll your own dispatch reaper script

by Tim Lucas

If you haven’t used it before, the reaper script is useful for restarting your Rails application’s FastCGI dispatchers.

It’s seems the reaper script in Edge rails now relies on the existance of PID files in the tmp/pids directory. If you want to replicate the old functionality, create your own ruby script and override the capistrano restart task to call your own script instead of the standard script/reaper.

The reaper script for one of my apps is simply:


#!/usr/bin/env ruby
for process in `ps axwwl`.grep(/dispatch\.fcgi/).collect { |s| s.split[1] }
  puts "Sending USR2 to dispatch.fcgi process #{process}"
  Process.kill("USR2", process.to_i)
end

The above code is in script/my_reaper and is called from the Capistrano deployment recipe as below:


task :restart, :roles => :app do
 run "ruby #{deploy_to}/current/script/process/my_reaper"
end
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Ping.fm
  • Twitthis

Related posts:

  1. The Script Typeface Jennifer continues her series on typefaces and looks at the...
  2. Famous Rails Screencast Gets an Update When Ruby on Rails was first introduced, nothing helped put...
  3. Roll Your Own Twitter Clone So, you want to build your own Twitter-style microblog? Raena...
  4. Top Ruby Frameworks Rails and Merb Join Forces It's not every day that two essentially competing web development...
  5. FullCodePress Update: CodeBlacks Bet On Beta CMS The New Zealand team have made an interesting choice of...

This post has one response so far

Sponsored Links

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.

Follow SitePoint on...