You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Steve Cohen <sc...@javactivity.org> on 2008/06/16 18:40:54 UTC
[daemon] - how to read status of a daemonized app
I have gotten daemon working with my application. I am using daemon to
launch tomcat with a special script that does some unusual things I need
to do. I created a script in /etc/rc.d/init.d to launch my daemon and
it successfully launches tomcat on boot with the proper settings needed
to run my app. My daemon appears in the RedHat services application,
where it can be started and stopped.
The only problem is with the "status" command. I have tried various
things copied from other daemon scripts that come with RedHat (running
under RHEL4) and I don't know enough to know a reliable way of getting
the status of a jsvc-launched application. Can someone explain how this
is done?
I tried this and it doesn't work. Even though Tomcat and my webapp are
running fine, the script reports "dead but pid file exists".
dostatus() {
_status mydaemon
}
_status() {
local base=${1##*/}
local pid
# Test syntax.
if [ "$#" = 0 ] ; then
echo $"Usage: status {program}"
return 1
fi
# First try "pidof"
pid=`/sbin/pidof -o $$ -o $PPID -o %PPID -x $1 || \
/sbin/pidof -o $$ -o $PPID -o %PPID -x ${base}`
if [ -n "$pid" ]; then
echo $"${base} (pid $pid) is running..."
return 0
fi
# Next try "/var/run/*.pid" files
if [ -f $PIDFILE ] ; then
read pid < $PIDFILE
if [ -n "$pid" ]; then
echo $"${base} dead but pid file exists"
return 1
fi
fi
# See if /var/lock/subsys/${base} exists
if [ -f /var/lock/subsys/${base} ]; then
echo $"${base} dead but subsys locked"
return 2
fi
echo $"${base} is stopped"
return 3
}
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org