Stopping Axis2 in unix

If you’re having trouble killing axis2 via a init.d script or otherwise on unix, just do this:

  1. AXIS2_CHILD_PID=`ps aux | egrep "axis2server.sh|SimpleAxis2Server" | grep -v "egrep" | awk '{print $2;}'`
  2. echo "Killing stubborn AXIS2 child process that won't die with parent.. pid is ${AXIS2_CHILD_PID}"
  3. kill ${AXIS2_CHILD_PID} >/dev/null 2>&1 && echo OK || echo "failed, what now?"

That works for axis 1.5.1, at least.

The odd thing about axis2 is, there isn’t any documentation mentioning axis2 daemonizing. The axis2server.sh script certainly does not appear to daemonize, and the axis2.xml config file doesnt seem to make any mention of a deamonizing configuration item.

Yet, when you run axis2server.sh in a terminal, it’s interactive, ctrl-c, and the the script and the child axis2 will be dead.

Run axis2server.sh as a background process, like so, and you’ll see the child pid hangs around for some reason:

  1.  
  2. jbaker$ axis2server.sh &
  3.  
  4. jbaker$ ps aux | grep axis2 | grep -v grep
  5. jbaker          2878   0.0  1.0  2926128  82144 s002  S+    6:17PM   0:01.63 /usr/bin/java (classpath omitted)
  6. jbaker          2872   0.0  0.0  2435488   1008 s002  S+    6:17PM   0:00.03 /bin/sh ./axis2server.sh
  7.  
  8. jbaker$ kill 2872
  9.  
  10. jbaker$ ps aux | grep axis2 | grep -v grep
  11. jbaker          2878   0.0  1.0  2925080  82100 s002  S     6:17PM   0:01.64 /usr/bin/java (classpath omitted)

Notice that killing 2872 not take 2878 along with it..

This is also posted on stackoverflow here. Maybe someone will come along and tell me a better way to do this..