jetty.sh stop hangs

Posted by Jen Tong on May 14, 2009

Jetty 6 is my favorite servlet container. It’s super fast, easy to embed, and very easy to use. I have run into one issue pretty often, though.

The built in jetty.sh script often hangs when given the stop command. This isn’t a big deal when I’m doing development, but it’s a problem when I’m trying to bounce Jetty in a test environment from continuous integration software like Hudson.

To solve this problem I came up with a very crude shell script to kill all jetty processes (including hung jetty.sh stop processes). It also manually exits 0 to feign success even if no Jetty is found. This keeps Hudson happy.

killjetty.sh:

#!/usr/xpg4/bin/sh
ps -ef | grep jetty | grep -v killjetty | grep -v grep | awk '{ print $2 }' | xargs kill -9
exit 0