RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1304220 - Tomcat init script does not respect setting of CATALINA_PID in /etc/sysconfig/tomcat
Summary: Tomcat init script does not respect setting of CATALINA_PID in /etc/sysconfig...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: tomcat
Version: 7.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Coty Sutherland
QA Contact: tomcat-qe
URL:
Whiteboard:
Depends On: 1104708
Blocks: 1298191
TreeView+ depends on / blocked
 
Reported: 2016-02-03 03:40 UTC by Coty Sutherland
Modified: 2016-02-03 03:49 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 1104708
Environment:
Last Closed: 2016-02-03 03:49:36 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Coty Sutherland 2016-02-03 03:40:21 UTC
+++ This bug was initially created as a clone of Bug #1104708 +++

Description of problem:
No matter what CATALINA_PID is set to in /etc/sysconfig/${NAME}, /etc/init.d/tomcat assumes the pid file is at /var/run/${NAME}.pid

Version-Release number of selected component (if applicable):
7.0.33-4

How reproducible:
Set CATALINA_PID to something other name /var/run/${NAME}.pid in /etc/sysconfig/${NAME}

Steps to Reproduce:
1. echo 'CATALINA_PID=/var/run/whatsmyname.pid' >> /etc/sysconfig/tomcat
2. service tomcat start

Actual results:
CATALINA_PID=/var/run/tomcat.pid

Expected results:
CATALINA_PID=/var/run/whatsmyname.pid

Additional info:
This ends up a problems because the Tomcat init script sets the ownership on CATALINA_PID to TOMCAT_USER:TOMCAT_GROUP so Tomcat can write to the file, but this will fail when CATALINA_PID is set to something other than /var/run/${NAME}.pid

--- Additional comment from Nico Kadel-Garcia on 2014-12-03 10:15:37 EST ---

The patch for this is below.

diff -ur tomcat-7.0.33-4.el6.pid/etc/init.d/tomcat tomcat-7.0.33-4.el6/etc/init.d/tomcat
--- tomcat-7.0.33-4.el6.pid/etc/init.d/tomcat   2014-12-03 10:12:51.689838620 -0500
+++ tomcat-7.0.33-4.el6/etc/init.d/tomcat       2014-12-03 10:10:49.812736936 -0500
@@ -69,6 +69,8 @@
 # Define the tomcat log file
 TOMCAT_LOG="${TOMCAT_LOG:-${CATALINA_HOME}/logs/${NAME}-initd.log}"

+# Define the tomcat pid file
+CATALINA_PID="${CATALINA_PID:-/var/run/${NAME}.pid}"

 RETVAL="0"

@@ -162,7 +164,6 @@
         fi
     fi
     # fix permissions on the log and pid files
-    export CATALINA_PID="/var/run/${NAME}.pid"
     touch $CATALINA_PID 2>&1 || RETVAL="4"
     if [ "$RETVAL" -eq "0" -a "$?" -eq "0" ]; then
       chown ${TOMCAT_USER}:${TOMCAT_USER} $CATALINA_PID
@@ -210,8 +211,8 @@
       fi
       if [ "$RETVAL" -eq "0" ]; then
          count="0"
-         if [ -s "/var/run/${NAME}.pid" ]; then
-            read kpid < /var/run/${NAME}.pid
+         if [ -s "$CATALINA_PID" ]; then
+            read kpid < $CATALINA_PID
             until [ "$(ps --pid $kpid | grep -c $kpid)" -eq "0" ] || \
                       [ "$count" -gt "$SHUTDOWN_WAIT" ]; do
                     if [ "$SHUTDOWN_VERBOSE" = "true" ]; then
@@ -228,7 +229,7 @@
                 fi
                 log_success_msg
             fi
-            rm -f /var/lock/subsys/${NAME} /var/run/${NAME}.pid
+            rm -f /var/lock/subsys/${NAME} $CATALINA_PID
         else
             log_failure_msg
             RETVAL="4"
@@ -262,7 +263,7 @@
         start
         ;;
     condrestart|try-restart)
-        if [ -s "/var/run/${NAME}.pid" ]; then
+        if [ -s "$CATALINA_PID" ]; then
             stop
             start
         fi
@@ -271,14 +272,14 @@
         RETVAL="3"
         ;;
     force-reload)
-        if [ -s "/var/run/${NAME}.pid" ]; then
+        if [ -s "$CATALINA_PID" ]; then
             stop
             start
         fi
         ;;
     status)
-        if [ -s "/var/run/${NAME}.pid" ]; then
-            read kpid < /var/run/${NAME}.pid
+        if [ -s "$CATALINA_PID" ]; then
+            read kpid < $CATALINA_PID
             if [ -d "/proc/${kpid}" ]; then
                 log_success_msg "${NAME} (pid ${kpid}) is running..."
                 RETVAL="0"

--- Additional comment from Coty Sutherland on 2016-02-02 22:38:39 EST ---

https://github.com/csutherl/fedora-tomcat/commit/017ab53

There was one missing /var/run/${NAME}.pid usage in the above patch, but other than that (which I added in the above commit) it looks good.

Comment 1 Coty Sutherland 2016-02-03 03:49:36 UTC
Oops...just realized that RHEL 7 tomcat now uses systemd instead of sysV. Closing this because it doesn't apply. I was looking at the dist-git repo; I need to clean up those unused files.


Note You need to log in before you can comment on or make changes to this bug.