LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Tomcat6 + CentOS 3/4/5"tomcat dead but subsys locked" (https://www.linuxquestions.org/questions/linux-software-2/tomcat6-centos-3-4-5-tomcat-dead-but-subsys-locked-715548/)

slinx 03-30-2009 01:42 PM

Tomcat6 + CentOS 3/4/5"tomcat dead but subsys locked"
 
BUT - Tomcat is NOT dead - Tomcat is fine. The status function just can't find the pid. When I set the CATALINA_PID variable to "/var/run/tomcat.pid" in catalina.sh, it stores the pid, but the status script just checks if the pid in pid file is a string, then reports this error if it is ! How can I make the status script recognize when tomcat is actually running?

We're running tomcat6 on CentOS 3, 4, and 5.

Thanks!

TB0ne 03-30-2009 03:29 PM

Quote:

Originally Posted by slinx (Post 3492787)
BUT - Tomcat is NOT dead - Tomcat is fine. The status function just can't find the pid. When I set the CATALINA_PID variable to "/var/run/tomcat.pid" in catalina.sh, it stores the pid, but the status script just checks if the pid in pid file is a string, then reports this error if it is ! How can I make the status script recognize when tomcat is actually running?

We're running tomcat6 on CentOS 3, 4, and 5.

Thanks!

No, it doesn't check to see if the PID in the pid file is a string...it looks AT that string, and checks the process table to see if it's there.

How are you starting and stopping Tomcat? I'd suggest stopping it totally...kill ALL threads and other things associated with it, then delete that tomcat.pid file. Start Tomcat up using the startup script, which should write the new PID into that file...status function should then be able to find it, since the PID will be valid.

slinx 03-31-2009 08:34 AM

I was using service start/stop tomcat

The catalina.sh was NOT writing the pid to the tomcat.pid file - I had to add the CATALINA_PID=/var/run/tomcat.pid variable to make it do that... but the behavior is the same EXCEPT on two CentOS 5 systems - the 3 and 4 systems still say tomcat is dead, yet the tomcat is still running and users can connect to it.

It does only look at the existence of the pid, it doesn't try to do anything with it - the test is merely [ -n $pid ]:
Code:

        # First try "pidof"
        pid=`pidof -o $$ -o $PPID -o %PPID -x $1 || \
            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 /var/run/${base}.pid ] ; then
                read pid < /var/run/${base}.pid
                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


slinx 03-31-2009 08:37 AM

OK, it seems that the pidof program is failing to see the process, because it's looking for something named "tomcat" when it's actually named "java". I edited the /etc/init.d/functions script to get the pid correctly, and the /opt/tomcat6/bin/catalina.sh script to write the PID, and to check if tomcat is already running before starting another process.


All times are GMT -5. The time now is 10:48 AM.