Uploaded image for project: 'JBoss Web Server'
  1. JBoss Web Server
  2. JWS-470

[RHEL 6 RPM] Confusing service status output for tomcat7 and tomcat8 installed both on RHEL system

    XMLWordPrintable

Details

    • 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

    Description

      status implementation in rpms init.d files of tomcat7 and tomcat8 does not distinguish between tomcat versions actually, see:

      1. Lets have RHEL server where there are installed both tomcat7 and tomcat8 from RPMs.
      2. Start the tomcat7 server using service tomcat7 start
      3. Check status of the tomcat7 and tomcat8 servers:
        # service tomcat7 status; service tomcat8 status
        tomcat7 (pid 6524) is running...
        tomcat8 (pid 6524) is running...
        
      4. Both the tomcat7 and tomcat8 servers seems to be running although only one (the tomcat7) is running actually.
      5. 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.

      Attachments

        Activity

          People

            rhn-support-csutherl Coty Sutherland
            jstourac@redhat.com Jan Stourac
            Jan Štefl Jan Štefl
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 3 hours
                3h
                Remaining:
                Remaining Estimate - 3 hours
                3h
                Logged:
                Time Spent - Not Specified
                Not Specified