|
|
937446 |
From a1860a5bbe5c63c6a34d9160a8aacffc61a89dcf Mon Sep 17 00:00:00 2001
|
|
|
937446 |
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
|
|
937446 |
Date: Fri, 16 Sep 2016 14:25:28 +0200
|
|
|
937446 |
Subject: [PATCH] tomcat: use systemd where available due to newer versions not
|
|
|
937446 |
generating PID-file
|
|
|
937446 |
|
|
|
937446 |
---
|
|
|
937446 |
heartbeat/tomcat | 44 ++++++++++++++++++++++++++++++++++++++++----
|
|
|
937446 |
1 file changed, 40 insertions(+), 4 deletions(-)
|
|
|
937446 |
|
|
|
937446 |
diff --git a/heartbeat/tomcat b/heartbeat/tomcat
|
|
|
937446 |
index 07a7ce4..813d280 100755
|
|
|
937446 |
--- a/heartbeat/tomcat
|
|
|
937446 |
+++ b/heartbeat/tomcat
|
|
|
937446 |
@@ -56,6 +56,10 @@ else
|
|
|
937446 |
SU=su
|
|
|
937446 |
fi
|
|
|
937446 |
|
|
|
937446 |
+if which systemctl > /dev/null 2>&1; then
|
|
|
937446 |
+ SYSTEMD=1
|
|
|
937446 |
+fi
|
|
|
937446 |
+
|
|
|
937446 |
############################################################################
|
|
|
937446 |
# Usage
|
|
|
937446 |
usage()
|
|
|
937446 |
@@ -90,6 +94,10 @@ isrunning_tomcat()
|
|
|
937446 |
#
|
|
|
937446 |
isalive_tomcat()
|
|
|
937446 |
{
|
|
|
937446 |
+ if ocf_is_true $SYSTEMD; then
|
|
|
937446 |
+ systemctl is-active tomcat@${TOMCAT_NAME} > /dev/null 2>&1
|
|
|
937446 |
+ return $?
|
|
|
937446 |
+ fi
|
|
|
937446 |
# As the server stops, the PID file disappears. To avoid race conditions,
|
|
|
937446 |
# we will have remembered the PID of a running instance on script entry.
|
|
|
937446 |
local pid=$rememberedPID
|
|
|
937446 |
@@ -184,9 +192,31 @@ rotate_catalina_out()
|
|
|
937446 |
}
|
|
|
937446 |
|
|
|
937446 |
############################################################################
|
|
|
937446 |
+# Create systemd configuration
|
|
|
937446 |
+create_systemd_config()
|
|
|
937446 |
+{
|
|
|
937446 |
+cat<<-EOF > /etc/sysconfig/tomcat@${TOMCAT_NAME}
|
|
|
937446 |
+JAVA_HOME=${JAVA_HOME}
|
|
|
937446 |
+JAVA_OPTS="${JAVA_OPTS}"
|
|
|
937446 |
+CATALINA_HOME=${CATALINA_HOME}
|
|
|
937446 |
+CATALINA_BASE=${CATALINA_BASE}
|
|
|
937446 |
+CATALINA_OUT=${CATALINA_OUT}
|
|
|
937446 |
+CATALINA_OPTS="${CATALINA_OPTS}"
|
|
|
937446 |
+CATALINA_TMPDIR="${CATALINA_TMPDIR}"
|
|
|
937446 |
+JAVA_ENDORSED_DIRS="${JAVA_ENDORSED_DIRS}"
|
|
|
937446 |
+LOGGING_CONFIG="${LOGGING_CONFIG}"
|
|
|
937446 |
+LOGGING_MANAGER="${LOGGING_MANAGER}"
|
|
|
937446 |
+TOMCAT_CFG=${TOMCAT_CFG}
|
|
|
937446 |
+EOF
|
|
|
937446 |
+}
|
|
|
937446 |
+
|
|
|
937446 |
+############################################################################
|
|
|
937446 |
# Tomcat Command
|
|
|
937446 |
tomcatCommand()
|
|
|
937446 |
{
|
|
|
937446 |
+ if ocf_is_true $SYSTEMD; then
|
|
|
937446 |
+ systemctl $@ tomcat@${TOMCAT_NAME}
|
|
|
937446 |
+ else
|
|
|
937446 |
cat<<-END_TOMCAT_COMMAND
|
|
|
937446 |
export JAVA_HOME=${JAVA_HOME}
|
|
|
937446 |
export JAVA_OPTS="${JAVA_OPTS}"
|
|
|
937446 |
@@ -202,6 +232,7 @@ cat<<-END_TOMCAT_COMMAND
|
|
|
937446 |
export TOMCAT_CFG=${TOMCAT_CFG}
|
|
|
937446 |
$TOMCAT_START_SCRIPT $@
|
|
|
937446 |
END_TOMCAT_COMMAND
|
|
|
937446 |
+ fi
|
|
|
937446 |
}
|
|
|
937446 |
attemptTomcatCommand()
|
|
|
937446 |
{
|
|
|
937446 |
@@ -209,7 +240,9 @@ attemptTomcatCommand()
|
|
|
937446 |
export TOMCAT_CFG=$(mktemp ${HA_RSCTMP}/tomcat-tmp-XXXXX.cfg)
|
|
|
937446 |
fi
|
|
|
937446 |
|
|
|
937446 |
- if [ "$RESOURCE_TOMCAT_USER" = root ]; then
|
|
|
937446 |
+ if ocf_is_true $SYSTEMD; then
|
|
|
937446 |
+ tomcatCommand $@
|
|
|
937446 |
+ elif [ "$RESOURCE_TOMCAT_USER" = root ]; then
|
|
|
937446 |
"$TOMCAT_START_SCRIPT" $@ >> "$TOMCAT_CONSOLE" 2>&1
|
|
|
937446 |
else
|
|
|
937446 |
tomcatCommand $@ | $SU - -s /bin/sh "$RESOURCE_TOMCAT_USER" >> "$TOMCAT_CONSOLE" 2>&1
|
|
|
937446 |
@@ -224,6 +257,9 @@ attemptTomcatCommand()
|
|
|
937446 |
# Start Tomcat
|
|
|
937446 |
start_tomcat()
|
|
|
937446 |
{
|
|
|
937446 |
+ if ocf_is_true $SYSTEMD; then
|
|
|
937446 |
+ create_systemd_config
|
|
|
937446 |
+ fi
|
|
|
937446 |
cd "$CATALINA_HOME/bin"
|
|
|
937446 |
|
|
|
937446 |
validate_all_tomcat || exit $?
|
|
|
937446 |
@@ -334,11 +370,11 @@ Resource script for Tomcat. It manages a Tomcat instance as a cluster resource.
|
|
|
937446 |
<parameters>
|
|
|
937446 |
|
|
|
937446 |
<parameter name="tomcat_name" unique="1" >
|
|
|
937446 |
-<longdesc lang="en">
|
|
|
937446 |
+<longdesc lang="en">
|
|
|
937446 |
The name of the resource, added as a Java parameter in JAVA_OPTS:
|
|
|
937446 |
--Dname=<tomcat_name> to Tomcat process on start. Used to ensure
|
|
|
937446 |
+-Dname=<tomcat_name> to Tomcat process on start. Used to ensure
|
|
|
937446 |
process is still running and must be unique.
|
|
|
937446 |
-]]></longdesc>
|
|
|
937446 |
+</longdesc>
|
|
|
937446 |
<shortdesc>The name of the resource</shortdesc>
|
|
|
937446 |
<content type="string" default="" />
|
|
|
937446 |
</parameter>
|