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

service tomcat{7|8} status may end with no info printed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • JWS 3.0.2 CR1
    • JWS 3.0.1 ER1
    • tomcat7, tomcat8
    • None
    • Release Notes
    • Documented as Resolved Issue

      In tomcat8 and tomcat7 init scripts there is switch with "status" branch and code in it:

              if [ -f "/var/run/${NAME}.pid" ]; then
      #           status ${NAME}
      #           RETVAL="$?"
                  read kpid < /var/run/${NAME}.pid
                  if [ -d "/proc/${kpid}" ]; then
                      echo "${NAME} (pid ${kpid}) is running..."
                      RETVAL="0"
                  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 case that particular pid file "/var/run/${NAME}.pid" exists but appropriate process has already exited then there is no message print to user and return code is 0. IMHO in this case user should be informed that particular service is not running and return value should be 3 according to the Linux Standard Base.

      I propose change like this:

      # diff -u tomcat8 tomcat8.new 
      --- tomcat8	2015-07-21 09:07:16.855704901 -0400
      +++ tomcat8.new	2015-07-21 09:07:05.929571026 -0400
      @@ -272,6 +272,10 @@
                   if [ -d "/proc/${kpid}" ]; then
                       echo "${NAME} (pid ${kpid}) is running..."
                       RETVAL="0"
      +            else
      +                echo "${NAME} is stopped"
      +                rm -f /var/run/${NAME}.pid # I really do not like reusing same code on multiple places...
      +                RETVAL="3"
                   fi
               else
                   pid="$(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_GROUP} java)"
      

              rhn-support-csutherl Coty Sutherland
              jstourac@redhat.com Jan Stourac
              Lucas Costi Lucas Costi (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: