in Rails

A better alternative to killall

On my host, severall other users are running other rails applications.

So, when using “rake deploy” while using Capistrano (used to be called SwitchTower before someone objected in infringed on their trademark), the default “killall -9 dispatch.fcgi” is trying to kill other processes that do not belong to me. This creates a problem near the end of the deploy command and it returns a failed status. In this case this is harmless, but… your brain has a tendency to learn to ignore errors when running deploy. Next time you get a real error, it might take you a while to realize that the error wasnt caused by the “killall” command. There is a better alternative where you can filter on the user: pkill.

So in deploy.rb, I’ve replace the

run “killall -9 dispatch.fcgi”

by

run “pkill -9 -u #{user} ruby”

on my config, the processes don’t show up as dispatch.fcgi, but as ruby dispatch.fgci

And, now, bliss is upon us:”rake deploy” completes with no error

Once I get more than one app hosted, I’ll figure out how to get Reaper to work.

  1. @Vishesh, it depends. kill will let you stop a given process, while killall will will stop all instances of a given process.

Comments are closed.