Blog Post RSS ?

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

Roll your own dispatch reaper script


  • Save to
    Del.icio.us

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

This post has one response so far

  1. wow! this tip really helped me, I couldn’t figure out why the default reaper script was so fixed on looking for the path and PID and not finding my dispatch.fcgi! this saved me a lot of time!

     

Sponsored Links

Leave a response

You are not logged in, log in with your SitePoint Forum username and password.

-OR- Post Anonymously

* Make sure any code samples are escaped (i.e. ‘<b>’ becomes ‘&lt;b&gt;’).

If not logged in, your comments will be placed in a moderation queue. This means your comment may not appear until one of our moderators approves it.

SitePoint Marketplace

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

Logo Design, Web page Design and more!

99designs

  • Custom logo designs created ‘just for you’.
  • Pick the design you like best.
  • Only pay if you’re satisfied with the result.

Want More Traffic?

Get up to five quotes from qualified SEO specialists, with no obligation!

Get A Free SEO Quote Now!