-
Bug
-
Resolution: Done
-
Critical
-
JWS 3.0.3 GA
-
Release Notes
-
-
-
-
-
-
The `service tomcat status` SysV command now returns the status of the correct tomcat instance when multiple tomcat instances are installed.
-
Documented as Resolved Issue
status implementation in rpms init.d files of tomcat7 and tomcat8 does not distinguish between tomcat versions actually, see:
- Lets have RHEL server where there are installed both tomcat7 and tomcat8 from RPMs.
- Start the tomcat7 server using service tomcat7 start
- Check status of the tomcat7 and tomcat8 servers:
# service tomcat7 status; service tomcat8 status tomcat7 (pid 6524) is running... tomcat8 (pid 6524) is running...
- Both the tomcat7 and tomcat8 servers seems to be running although only one (the tomcat7) is running actually.
- This works also vice versa
Problematic code is here:
/etc/init.d/tomcat7
status)
if [ -f "${CATALINA_PID}" ]; then
# status ${NAME}
# RETVAL="$?"
read kpid < ${CATALINA_PID}
if [[ -d "/proc/${kpid}" && ! -z $(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_GROUP} java) ]]; then
echo "${NAME} (pid ${kpid}) is running..."
RETVAL="0"
else
echo "${NAME} is stopped, but pid file (${CATALINA_PID}) still exists."
RETVAL="1"
fi
else
pid="$(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_GROUP} java)"
if [ -z "$pid" ]; then
# status ${NAME}
# RETVAL="$?"
echo "${NAME} is stopped"
RETVAL="3"
else
echo "${NAME} (pid $pid) is running..."
RETVAL="0"
fi
fi
;;
In the else branch, there is called /usr/bin/pgrep which does not distinguish between tomcat versions actually (just checks tomcat user and group, which is same for both 7 and 8 versions).
I have tried to fix this by following patch that seems to fix the mentioned problem:
--- /etc/init.d/tomcat7.backup 2016-06-06 06:49:16.338657271 -0400
+++ /etc/init.d/tomcat7 2016-06-06 06:48:06.515358060 -0400
@@ -276,7 +276,7 @@
RETVAL="1"
fi
else
- pid="$(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_GROUP} java)"
+ pid="$(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_GROUP} -f ${NAME})"
if [ -z "$pid" ]; then
# status ${NAME}
# RETVAL="$?"
I expect service tomcat{7|8} status command to output real status of appropriate service.