2005/4/22, Ian F. Darwin <[EMAIL PROTECTED]>: > Henri Gomez wrote: > > >I know that but if your starter wrapper check if the process whom pid > >is stored on the file is still alive it could determine if the process > >has been aborted via kill -9. > > > >I'm using this kind of hack in Linux init.d rc for at least 2 years, > >whitout problems > > > > > > > Right, if you read the PID and send it a signal to ensure it's still > alive at the OS level, you get quite a bit of reliability.
Here's part of my init.d script : .... TOMCAT_CFG="/etc/tomcat55/conf/tomcat55.conf" [ -r "$TOMCAT_CFG" ] && . "${TOMCAT_CFG}" if [ -x /etc/rc.d/init.d/functions ]; then . /etc/rc.d/init.d/functions else # Check if $pid (could be plural) are running checkpid() { local i for i in $* ; do [ -d "/proc/$i" ] && return 0 done return 1 } fi .... start() { echo -n "Starting $TOMCAT_PROG: " if [ -f /var/lock/subsys/tomcat55 ] ; then read kpid < /var/run/tomcat55.pid if checkpid $kpid 2>&1; then echo "process allready running" return -1 else echo "lock file found but no process running for pid $kpid, continuing" fi fi if [ -x /etc/rc.d/init.d/functions ]; then daemon --user $TOMCAT_USER $TOMCAT_SCRIPT start else su - $TOMCAT_USER -c "$TOMCAT_SCRIPT start" fi RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat55 return $RETVAL } stop() { echo -n "Stopping $TOMCAT_PROG: " if [ -f /var/lock/subsys/tomcat55 ] ; then if [ -x /etc/rc.d/init.d/functions ]; then daemon --user $TOMCAT_USER $TOMCAT_SCRIPT stop else su - $TOMCAT_USER -c "$TOMCAT_SCRIPT stop" fi RETVAL=$? echo RETVAL=$? echo if [ $RETVAL = 0 ]; then let count=0; if [ -f /var/run/tomcat55.pid ] && [ ! -z /var/run/tomcat55.pid ]; then read kpid < /var/run/tomcat55.pid let kwait=$SHUTDOWN_WAIT until [ `ps --pid $kpid | grep -c $kpid` = '0' ] || [ $count -gt $kwait ] do echo "waiting for processes to finish"; sleep 1 let count=$count+1; done if [ $count -gt $kwait ]; then echo "killing processes which didn't stop after $SHUTDOWN_WAIT seconds" /bin/kill -9 $kpid fi fi rm -f /var/lock/subsys/tomcat55 /var/run/tomcat55.pid fi fi } part of my TOMCAT_SCRIPT : TOMCAT_CFG="/etc/tomcat55/conf/tomcat55.conf" [ -r "$TOMCAT_CFG" ] && . "${TOMCAT_CFG}" java ${JAVA_OPTS} ${HEADLESS} -Djava.endorsed.dirs=/var/tomcat55/common/endorsed -Dcatalina.base=/var/tomcat55 -Dcatalina.home=/var/tomcat55 -Djava.io.tmpdir=/var/tomcat55/temp -classpath ${CLASSPATH} org.apache.catalina.startup.Bootstrap $@ >> /var/log/tomcat55/tomcat55.log 2>&1 & if [ ! -z "$TOMCAT_PID" ] && [ "$1" != "stop" ] ; then echo $! > $TOMCAT_PID fi As you could see the TOMCAT_SCRIPT grab the tomcat main process id via $! Bash power :-) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]