Topic: Killing process via Capistrano

Lets say I've got multiple java apps running on my app server, and I want to kill only the one defined as 'application' in my deployment recipe.  I send a cmd block like this:

ps auxww | grep java | grep -i #{application} | awk '{print $2}' |xargs kill -9

The statement does what it was written to do, the application is killed successfully. But here is  the kicker:  Capistrano reports that the command failed... even though it did NOT fail. I don't know what the command is returning, but capistrano doesn't like it.

Here's an example output from capistrano

[root@foobar foo_service]# RAILS_ENV=qa TARGET_BRANCH=trunk cap stop_foo_service
  * executing task stop_foo_service
  * executing "ps auxww | grep java | grep -i fooservice | awk '{print $2}' |xargs kill -9"
    servers: ["app1.company.local"]
    [qaurapp1.jobster.local] executing command
    command finished
command "ps auxww | grep java | grep -i fooservice | awk '{print $2}' |xargs kill -9" failed on app1.company.local


Anyone know how to get around this? What is the kill command returning that capistrano think is a fail? I can't include it in any transactional tasks, like deploying, cause cap will fail it.

Re: Killing process via Capistrano

I don't really know anything about what you're trying to do, but kill -9 is not nice.  Kill -9 should only used when processes are hung.  A 'normal' kill (SIGINT) is usually what is used to kill a process, which lets it shutdown cleanly.

BrewControl.com - Brewery and Brewpub management powered by RoR

Re: Killing process via Capistrano

I changed the kill signal to (2) instead of (9) and that resolved the issue. Still curious as to why cap was marking the kill -9 as a failure.

Thanks!!

Last edited by tims (2007-04-02 20:21:02)

Re: Killing process via Capistrano

Probably because of its return value...  No problem.

BrewControl.com - Brewery and Brewpub management powered by RoR