admin管理员组

文章数量:1403084

After a reboot Tomcat didn't start due to a existing PID file:

/opt/tomcat/bin # ./version.sh
Using CATALINA_BASE:   /opt/tomcat
Using CATALINA_HOME:   /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME:        /usr/lib/jvm/temurin-17-jre-amd64
Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:    -Xmx6000M -Xms6000M -XX:InitialCodeCacheSize=128M -XX:ReservedCodeCacheSize=128M ...
Using CATALINA_PID:    /opt/tomcat/work/catalina.pid
Server version: Apache Tomcat/10.1.28
Server built:   Aug 2 2024 15:14:43 UTC
Server number:  10.1.28.0
OS Name:        Linux
OS Version:     5.15.0-134-generic
Architecture:   amd64
JVM Version:    17.0.14+7
JVM Vendor:     Eclipse Adoptium

Why doesn't the CATALINA_PID point to sst like "/run/..." (which is a tmpfs and empty after reboot)?

The systemctl servicefile runs the commands as user "tomcat" so it can't create "/run/tomcat/".

As far as I can see, there are two bad options (with a common core) and a third really ugly one:

  1. Let CATALINA_PID point to "/run/tomcat/catalina.pid" and create the dir in advance writable for tomcat.tomcat

  2. Delete the /opt/tomcat/work/catalina.pid after reboot deterministic before Tomcat starts.

  3. Rewrite the startingprocess according to FSH and systemd "standard"

  4. (uaf): Check after reboot, if (Tomcat is enabled and Tomcat not running and pid is older than uptime), removing pid and starting Tomcat.

Any other suggestions or ideas for a general solution?

After a reboot Tomcat didn't start due to a existing PID file:

/opt/tomcat/bin # ./version.sh
Using CATALINA_BASE:   /opt/tomcat
Using CATALINA_HOME:   /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME:        /usr/lib/jvm/temurin-17-jre-amd64
Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:    -Xmx6000M -Xms6000M -XX:InitialCodeCacheSize=128M -XX:ReservedCodeCacheSize=128M ...
Using CATALINA_PID:    /opt/tomcat/work/catalina.pid
Server version: Apache Tomcat/10.1.28
Server built:   Aug 2 2024 15:14:43 UTC
Server number:  10.1.28.0
OS Name:        Linux
OS Version:     5.15.0-134-generic
Architecture:   amd64
JVM Version:    17.0.14+7
JVM Vendor:     Eclipse Adoptium

Why doesn't the CATALINA_PID point to sst like "/run/..." (which is a tmpfs and empty after reboot)?

The systemctl servicefile runs the commands as user "tomcat" so it can't create "/run/tomcat/".

As far as I can see, there are two bad options (with a common core) and a third really ugly one:

  1. Let CATALINA_PID point to "/run/tomcat/catalina.pid" and create the dir in advance writable for tomcat.tomcat

  2. Delete the /opt/tomcat/work/catalina.pid after reboot deterministic before Tomcat starts.

  3. Rewrite the startingprocess according to FSH and systemd "standard"

  4. (uaf): Check after reboot, if (Tomcat is enabled and Tomcat not running and pid is older than uptime), removing pid and starting Tomcat.

Any other suggestions or ideas for a general solution?

Share Improve this question edited Mar 21 at 20:50 andrewJames 22.1k11 gold badges30 silver badges65 bronze badges asked Mar 21 at 12:35 maniac_on_moonmaniac_on_moon 1492 silver badges7 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

Solution: Deviate from Tomcat default and use "tmpfiles.d"

echo "d /run/tomcat 0755 tomcat tomcat -" | sudo bash -c "cat - > /etc/tmpfiles.d/tomcat.conf"
sudo systemd-tmpfiles --create

point

CATALINA_PID="/run/tomcat/catalina.pid"

and restart Tomcat.
Other references with similar issues and no (reliable) solution:
first second third fourth
(Thanks to @andrewJames for editing)

本文标签: linuxTomcat did not restart after reboot due to existing PID file on ubuntu 2204Stack Overflow