How to handle commands that hang on the remote end?

Skip to first unread message

Haani Niyaz

May 15, 2016, 10:23:51 PM5/15/16
to Capistrano
We have a use case where we want to run a service tomcat stop command and if it hangs run a kill -9 <pid> command. I'm unaware of ways to handle this in Capistrano. 
Has anyone solved a similar issue..? if so, can you please share methods, thanks.

  • Ruby 2.1.1p76
  • Capistrano 3.4.0 

Lee Hambley

May 18, 2016, 12:46:56 PM5/18/16
to Capistrano
Hi Haani,

It's been 48 since your post, so I'm not sure if it's still relevant, however if tomcat is taking a long time to respond, there's not much Capistrano can do to handle that. 

The only real way is to make a command that backgrounds tomcat, collects it's PID and then signals it after a certain number of seconds, but it ends up being quite convoluted.

Bash's (assuming you're using the Bourne shell) FAQ #68 has a wealth of good information:

You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web, visit
For more options, visit

Haani Niyaz

May 18, 2016, 6:01:06 PM5/18/16
to Capistrano
Thanks Lee. It does seem like something that should be handled by the tomcat init script so I've resorted to doing just that.
Reply all
Reply to author
0 new messages