commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Cohen <>
Subject [daemon] - how to read status of a daemonized app
Date Mon, 16 Jun 2008 16:40:54 GMT
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

# 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

# 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
# See if /var/lock/subsys/${base} exists
if [ -f /var/lock/subsys/${base} ]; then
echo $"${base} dead but subsys locked"
return 2
echo $"${base} is stopped"
return 3

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message