- fix bnc#771802 - systemd support is broken
* change type froking to simple as it does not make a sense run java in a background to emulate that * remove the need of nested wrappers, so /usr/sbin/tomcat-sysd now relies on systemd features like User/EnvironmentFile * workaround the 143 exit code in Stop phase - return 0 in this case OBS-URL: https://build.opensuse.org/package/show/Java:packages/tomcat?expand=0&rev=5
This commit is contained in:
parent
683475e52e
commit
a1a7392be9
@ -2,87 +2,87 @@
|
|||||||
#
|
#
|
||||||
# This script provides systemd activation of the tomcat service
|
# This script provides systemd activation of the tomcat service
|
||||||
# To create clones of this service:
|
# To create clones of this service:
|
||||||
# 1) SERVICE_NAME must be defined before calling this script
|
# 1) Create /etc/tomcat/${SERVICE_NAME}.conf from /etc/tomcat/tomcat.conf
|
||||||
# 2) Create /etc/sysconfig/${SERVICE_NAME} from /etc/sysconfig/tomcat
|
# to override tomcat defaults and add the EnvironmentFile=
|
||||||
# to override tomcat defaults
|
# 2) Change the location of PIDFile=
|
||||||
|
|
||||||
# SERVICE_NAME is a required value only if the service name is
|
#### from /usr/sbin/dtomcat
|
||||||
# different from 'tomcat'
|
if [[ -r /usr/share/java-utils/java-functions ]]; then
|
||||||
#
|
. /usr/share/java-utils/java-functions
|
||||||
NAME="${SERVICE_NAME:-tomcat}"
|
|
||||||
|
|
||||||
#I'll bet this isn't required.
|
|
||||||
# unset ISBOOT
|
|
||||||
|
|
||||||
# For SELinux we need to use 'runuser' not 'su'
|
|
||||||
if [ -x "/sbin/runuser" ]; then
|
|
||||||
SU="/sbin/runuser -s /bin/sh"
|
|
||||||
else
|
else
|
||||||
SU="/bin/su -s /bin/sh"
|
echo "Can't read Java functions library, aborting" >&2
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Path to the tomcat launch script
|
set_javacmd
|
||||||
TOMCAT_SCRIPT="/usr/sbin/tomcat"
|
|
||||||
|
# CLASSPATH munging
|
||||||
# Define the tomcat username
|
if [[ -n "$JSSE_HOME" ]]; then
|
||||||
TOMCAT_USER="${TOMCAT_USER:-tomcat}"
|
CLASSPATH="${CLASSPATH}:$(build-classpath jcert jnet jsse 2>/dev/null)"
|
||||||
|
|
||||||
# TOMCAT_LOG should be different from catalina.out.
|
|
||||||
# Usually the below config is all that is necessary
|
|
||||||
TOMCAT_LOG=/var/log/${NAME}/${NAME}-sysd.log
|
|
||||||
|
|
||||||
# Get the tomcat config (use this for environment specific settings)
|
|
||||||
TOMCAT_CFG="/etc/tomcat/tomcat.conf"
|
|
||||||
if [ -r "$TOMCAT_CFG" ]; then
|
|
||||||
. $TOMCAT_CFG
|
|
||||||
fi
|
fi
|
||||||
|
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/bootstrap.jar"
|
||||||
# Get instance specific config file
|
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/tomcat-juli.jar"
|
||||||
if [ -r "/etc/sysconfig/${NAME}" ]; then
|
CLASSPATH="${CLASSPATH}:$(build-classpath commons-daemon 2>/dev/null)"
|
||||||
. /etc/sysconfig/${NAME}
|
|
||||||
fi
|
|
||||||
|
|
||||||
function parseOptions() {
|
|
||||||
options=""
|
|
||||||
options="$options $(
|
|
||||||
awk '!/^#/ && !/^$/ { ORS=" "; print "export ", $0, ";" }' \
|
|
||||||
$TOMCAT_CFG
|
|
||||||
)"
|
|
||||||
if [ -r "/etc/sysconfig/${NAME}" ]; then
|
|
||||||
options="$options $(
|
|
||||||
awk '!/^#/ && !/^$/ { ORS=" ";
|
|
||||||
print "export ", $0, ";" }' \
|
|
||||||
/etc/sysconfig/${NAME}
|
|
||||||
)"
|
|
||||||
fi
|
|
||||||
TOMCAT_SCRIPT="$options ${TOMCAT_SCRIPT}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# See how we were called.
|
# See how we were called.
|
||||||
function start() {
|
function start() {
|
||||||
# fix permissions on the log and pid files
|
|
||||||
export CATALINA_PID="/var/run/${NAME}.pid"
|
local ret
|
||||||
touch $CATALINA_PID 2>&1
|
|
||||||
if [ "$?" -eq "0" ]; then
|
# running as root is not recommended in any case!
|
||||||
chown ${TOMCAT_USER}:${TOMCAT_USER} $CATALINA_PID
|
if [[ $(id -u) == 0 ]]; then
|
||||||
|
echo "ERROR: starting tomcat under uid 0 is not supported" >&2
|
||||||
|
echo " use appropriate User/Group settings in service file" >&2
|
||||||
|
echo " see man systemd.exec for details" >&2
|
||||||
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
touch $TOMCAT_LOG 2>&1
|
if [[ "$SECURITY_MANAGER" = "true" ]]; then
|
||||||
if [ "$?" -eq "0" ]; then
|
DSECURITY_MANAGER="-Djava.security.manager"
|
||||||
chown ${TOMCAT_USER}:${TOMCAT_USER} $TOMCAT_LOG
|
|
||||||
fi
|
|
||||||
|
|
||||||
parseOptions
|
|
||||||
if [ "$SECURITY_MANAGER" = "true" ]; then
|
|
||||||
$SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start-security" >> $TOMCAT_LOG 2>&1
|
|
||||||
else
|
else
|
||||||
$SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start" >> $TOMCAT_LOG 2>&1
|
unset DSECURITY_MANAGER
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
${JAVACMD} $JAVA_OPTS $CATALINA_OPTS \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
-Dcatalina.base="$CATALINA_BASE" \
|
||||||
|
-Dcatalina.home="$CATALINA_HOME" \
|
||||||
|
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
|
||||||
|
-Djava.io.tmpdir="$CATALINA_TMPDIR" ${DSECURITY_MANAGER} \
|
||||||
|
-Djava.util.logging.config.file="${CATALINA_BASE}/conf/logging.properties" \
|
||||||
|
-Djava.util.logging.manager="org.apache.juli.ClassLoaderLogManager" \
|
||||||
|
org.apache.catalina.startup.Bootstrap start
|
||||||
|
ret=${?}
|
||||||
|
|
||||||
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
function stop() {
|
function stop() {
|
||||||
parseOptions
|
|
||||||
$SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} stop" >> $TOMCAT_LOG 2>&1
|
local ret
|
||||||
|
|
||||||
|
${JAVACMD} $JAVA_OPTS \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
-Dcatalina.base="$CATALINA_BASE" \
|
||||||
|
-Dcatalina.home="$CATALINA_HOME" \
|
||||||
|
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
|
||||||
|
-Djava.io.tmpdir="$CATALINA_TMPDIR" \
|
||||||
|
org.apache.catalina.startup.Bootstrap stop
|
||||||
|
ret=${?}
|
||||||
|
|
||||||
|
if [[ ret == 143 ]]; then
|
||||||
|
ret=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return $ret
|
||||||
|
}
|
||||||
|
|
||||||
|
function version() {
|
||||||
|
|
||||||
|
exec ${JAVACMD} -classpath ${CATALINA_HOME}/lib/catalina.jar \
|
||||||
|
org.apache.catalina.util.ServerInfo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# See how we were called.
|
# See how we were called.
|
||||||
@ -97,5 +97,11 @@ case "$1" in
|
|||||||
stop
|
stop
|
||||||
start
|
start
|
||||||
;;
|
;;
|
||||||
|
version)
|
||||||
|
version
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop|restart|version}" >&2
|
||||||
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@ CATALINA_TMPDIR="@@@TCTEMP@@@"
|
|||||||
#JAVA_OPTS="-Djava.library.path=@@@LIBDIR@@@"
|
#JAVA_OPTS="-Djava.library.path=@@@LIBDIR@@@"
|
||||||
|
|
||||||
# What user should run tomcat
|
# What user should run tomcat
|
||||||
TOMCAT_USER="tomcat"
|
# WARNING: systemd will use values in tomcat.service!
|
||||||
|
#TOMCAT_USER="tomcat"
|
||||||
|
|
||||||
# You can change your tomcat locale here
|
# You can change your tomcat locale here
|
||||||
#LANG="en_US"
|
#LANG="en_US"
|
||||||
@ -32,7 +33,8 @@ SHUTDOWN_WAIT="30"
|
|||||||
SHUTDOWN_VERBOSE="false"
|
SHUTDOWN_VERBOSE="false"
|
||||||
|
|
||||||
# Set the TOMCAT_PID location
|
# Set the TOMCAT_PID location
|
||||||
CATALINA_PID="/var/run/tomcat.pid"
|
# WARNING: does not make any sense for systemd users
|
||||||
|
#CATALINA_PID="/var/run/tomcat.pid"
|
||||||
|
|
||||||
# Connector port is 8080 for this tomcat instance
|
# Connector port is 8080 for this tomcat instance
|
||||||
#CONNECTOR_PORT="8080"
|
#CONNECTOR_PORT="8080"
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
# Systemd unit file for tomcat
|
# Systemd unit file for tomcat
|
||||||
#
|
#
|
||||||
# To create clones of this service:
|
# You can clone this service by adding a new EnvironmentFile declaring the new
|
||||||
# 1) By default SERVICE_NAME=tomcat. When cloned, the value must be defined
|
# values for CATALINA_BASE et all
|
||||||
# before tomcat-sysd is called.
|
|
||||||
# 2) Create /etc/sysconfig/${SERVICE_NAME} from /etc/sysconfig/tomcat
|
|
||||||
# to override tomcat defaults
|
|
||||||
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Apache Tomcat Web Application Container
|
Description=Apache Tomcat Web Application Container
|
||||||
After=syslog.target network.target
|
After=syslog.target network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=simple
|
||||||
|
EnvironmentFile=/etc/tomcat/tomcat.conf
|
||||||
|
User=tomcat
|
||||||
|
Group=tomcat
|
||||||
ExecStart=/usr/sbin/tomcat-sysd start
|
ExecStart=/usr/sbin/tomcat-sysd start
|
||||||
ExecStop=/usr/sbin/tomcat-sysd stop
|
ExecStop=-/usr/sbin/tomcat-sysd stop
|
||||||
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Jul 17 14:16:37 UTC 2012 - mvyskocil@suse.cz
|
||||||
|
|
||||||
|
- fix bnc#771802 - systemd support is broken
|
||||||
|
* change type froking to simple as it does not make a sense run java in a
|
||||||
|
background to emulate that
|
||||||
|
* remove the need of nested wrappers, so /usr/sbin/tomcat-sysd now relies on
|
||||||
|
systemd features like User/EnvironmentFile
|
||||||
|
* workaround the 143 exit code in Stop phase - return 0 in this case
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Wed Jun 13 12:37:49 UTC 2012 - mvyskocil@suse.cz
|
Wed Jun 13 12:37:49 UTC 2012 - mvyskocil@suse.cz
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ Source13: jasper-el-OSGi-MANIFEST.MF
|
|||||||
Source14: jasper-OSGi-MANIFEST.MF
|
Source14: jasper-OSGi-MANIFEST.MF
|
||||||
Source15: tomcat-api-OSGi-MANIFEST.MF
|
Source15: tomcat-api-OSGi-MANIFEST.MF
|
||||||
Source16: tomcat-juli-OSGi-MANIFEST.MF
|
Source16: tomcat-juli-OSGi-MANIFEST.MF
|
||||||
Source17: %{name}-%{major_version}.%{minor_version}-tomcat-sysd
|
Source17: tomcat-7.0-tomcat-sysd
|
||||||
Source18: %{name}-%{major_version}.%{minor_version}-tomcat-jsvc-sysd
|
Source18: %{name}-%{major_version}.%{minor_version}-tomcat-jsvc-sysd
|
||||||
Source19: %{name}-%{major_version}.%{minor_version}-jsvc.wrapper
|
Source19: %{name}-%{major_version}.%{minor_version}-jsvc.wrapper
|
||||||
Source20: %{name}-%{major_version}.%{minor_version}-jsvc.service
|
Source20: %{name}-%{major_version}.%{minor_version}-jsvc.service
|
||||||
|
Loading…
x
Reference in New Issue
Block a user