Originally posted by: EricFetzer
OK, we appear to be getting closer. I now have it starting the service (it calls a shell script that kicks off a java process). Then when I stop the service, it kills the shell script (which really wasn't doing anything anyway). I need it to also kill the java process. I thought I would accomplish that with my kill command but it's just killing the shell script. Here's the code:
#!/bin/ksh
trap "stopService" SIGTERM SIGHUP SIGQUIT SIGKILL
stopService()
{
#cleanup stuff
kill -15 `ps -ef | grep $CHILD|awk ' $2 ~ /'$CHILD'/ {print $2}'|tr '\n' ' '`
exit 0
}
while true
do
#Start jar
cd /opt/MyApp
java -classpath lib/log4j-1.2.17.jar:lib/ojdbc6-11.2.0.2.0.jar:./MyApp.jar:./ Main deploy/MyApp.properties
done
Here's what the processes look like after start:
was 9437416 2359492 0 12:18:17 - 0:00 /bin/ksh /opt/MyApp/startMyApp.sh
was 10879170 9437416 0 12:18:17 - 0:02 java -classpath lib/log4j-1.2.17.jar:lib/ojdbc6-11.2.0.2.0.jar:./MyApp.jar:./ Main deploy/MyApp.properties
Then after I stop the service:
was 10879170 1 0 12:18:17 - 0:02 java -classpath lib/log4j-1.2.17.jar:lib/ojdbc6-11.2.0.2.0.jar:./MyApp.jar:./ Main deploy/MyApp.properties
So instead of the child process getting stopped, it got taken over by the init process.