Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
www-servers/tomcat: add systemd support, bump to EAPI 6.
As part of systemd support multi instance feature reworked a bit: 1. Instance manager dropped. OpenRC init script may be symlinked now. 2. Instances are managed through config files in /etc/conf.d 3. By default instances are located in /var/lib/tomcats folder as in RHEL Fixes: https://bugs.gentoo.org/show_bug.cgi?id=485000 Fixes: https://bugs.gentoo.org/show_bug.cgi?id=567892
- Loading branch information
Showing
9 changed files
with
794 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Systemd unit file for tomcat instances. | ||
# | ||
# To create clones of this service: | ||
# 0. systemctl enable tomcat@name.service | ||
# 1. create catalina.base directory structure in | ||
# /var/lib/tomcats/name | ||
# 2. profit. | ||
|
||
[Unit] | ||
Description=Apache Tomcat Web Application Container | ||
After=syslog.target network.target | ||
|
||
[Service] | ||
Type=simple | ||
Environment="CATALINA_INSTANCE=%i" | ||
EnvironmentFile=/etc/conf.d/tomcat-@SLOT@ | ||
EnvironmentFile=-/etc/conf.d/tomcat-@SLOT@.%I | ||
ExecStart=/usr/libexec/tomcat/server-@SLOT@ start | ||
ExecStop=/usr/libexec/tomcat/server-@SLOT@ stop | ||
SuccessExitStatus=143 | ||
User=%I | ||
Group=%I | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# System-wide configuration file for tomcat services | ||
# This will be loaded by systemd/openrc as an environment file, | ||
# so please keep the syntax. | ||
# | ||
# Use this file to change default values for all services. | ||
# Change the service specific ones to affect only one service | ||
# in /etc/tomcat/conf.d/tomcat-@SLOT@.${CATALINA_INSTANCE} | ||
|
||
|
||
# In new-style instances, if CATALINA_BASE isn't specified, it will | ||
# be constructed by joining TOMCATS_BASE and CATALINA_INSTANCE. | ||
# | ||
TOMCATS_BASE="/var/lib/tomcats/" | ||
|
||
# Catalina instance name. | ||
# | ||
# Defaults: | ||
# openrc - part of init script name after dot; | ||
# systemd - instance name as defined in systemd.unit(5) | ||
# | ||
#CATALINA_INSTANCE="tomcat-@SLOT@" | ||
|
||
# Set the handle of the JVM to use. If unset uses the system-vm. | ||
# run 'eselect java-vm list' to get possible values. | ||
# | ||
#TOMCAT_JVM="icedtea-7" | ||
|
||
# Additional options to pass to the JVM. | ||
# Example to set library path for tomcat-native: | ||
# JAVA_OPTS="-Djava.library.path=/usr/lib" | ||
# | ||
#JAVA_OPTS="" | ||
|
||
# Options to pass to the JVM in addition to | ||
# JAVA_OPTS. This may be placed to per-instance | ||
# configuration files to extend default JAVA_OPTS | ||
# | ||
#JAVA_INSTANCE_OPTS="" | ||
|
||
# Additional packages to put on the default classpath. | ||
# jakarta-jstl is needed for some of the examples. | ||
# Note: The extra jars listed here will be visible to webapps. | ||
# Example: | ||
# TOMCAT_EXTRA_JARS="jakarta-jstl,xerces-2" | ||
# | ||
#TOMCAT_EXTRA_JARS="" | ||
|
||
# Additional paths to put on the default classpath. | ||
# These should be separated by the : character. | ||
# Note: The extra jars listed here will be visible to webapps. | ||
# Example: | ||
# TOMCAT_EXTRA_CLASSPATH="/path/to/foo.jar:/path/to/bar.jar" | ||
# | ||
#TOMCAT_EXTRA_CLASSPATH="" | ||
|
||
# User/Group of this instance. | ||
CATALINA_USER=tomcat | ||
CATALINA_GROUP=tomcat | ||
|
||
# Directory path location of temporary directory the JVM should | ||
# use (java.io.tmpdir). | ||
# Note: This directory must exist and be read/writable by tomcat. | ||
# See #246362 as an example where /var/tmp was deleted on shutdown. | ||
# | ||
CATALINA_TMPDIR="@GENTOO_PORTAGE_EPREFIX@/var/cache/tomcat-@SLOT@/temp" | ||
|
||
# Working directory. Default to $CATALINA_TMPDIR | ||
# | ||
#CATALINA_WORKDIR="@GENTOO_PORTAGE_EPREFIX@/var/cache/tomcat-@SLOT@/temp" | ||
|
||
# TOMCAT STARTUP | ||
# debug Start Catalina in a debugger | ||
# -security debug Debug Catalina with a security manager | ||
# jpda start Start Catalina under JPDA debugger | ||
# start Start Catalina in a separate window | ||
# -security start Start in a separate window with security manager | ||
# | ||
#TOMCAT_START="start" | ||
|
||
# Java Platform Debugger Architecture (JPDA) | ||
# http://java.sun.com/products/jpda/ | ||
# Override default JPDA address and transport for the "jpda start" command. | ||
# | ||
#JPDA_ADDRESS="8000" | ||
#JPDA_TRANSPORT="dt_socket" | ||
|
||
# Additional options to pass to catalina | ||
# | ||
#CATALINA_OPTS="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!@GENTOO_PORTAGE_EPREFIX@/sbin/runscript | ||
# Copyright 1999-2016 Gentoo Foundation | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
extra_commands="forcestop" | ||
|
||
PIDFILE=@GENTOO_PORTAGE_EPREFIX@/var/run/${RC_SVCNAME}.pid | ||
|
||
: ${CATALINA_INSTANCE:=${RC_SVCNAME##*.}} | ||
: ${CATALINA_USER:=tomcat} | ||
: ${CATALINA_GROUP:=tomcat} | ||
: ${CATALINA_TMPDIR:=@GENTOO_PORTAGE_EPREFIX@/var/cache/tomcat-@SLOT@/tmp} | ||
|
||
depend() { | ||
use dns logger net | ||
} | ||
|
||
start() { | ||
ebegin "Starting ${RC_SVCNAME}" | ||
|
||
start-stop-daemon --start \ | ||
--quiet --background \ | ||
--chdir "${CATALINA_TMPDIR}" \ | ||
--user ${CATALINA_USER}:${CATALINA_GROUP} \ | ||
--make-pidfile --pidfile ${PIDFILE} \ | ||
--exec @GENTOO_PORTAGE_EPREFIX@/usr/libexec/tomcat/server-@SLOT@ -- start | ||
|
||
eend $? | ||
} | ||
|
||
stop() { | ||
ebegin "Stopping '${RC_SVCNAME}'" | ||
|
||
start-stop-daemon --stop \ | ||
--quiet --retry=60 \ | ||
--pidfile ${PIDFILE} \ | ||
--exec @GENTOO_PORTAGE_EPREFIX@/usr/libexec/tomcat/server-@SLOT@ -- stop | ||
|
||
eend $? | ||
} | ||
|
||
forcestop() { | ||
ebegin "Forcing '${RC_SVCNAME}' to stop" | ||
|
||
start-stop-daemon --stop \ | ||
--quiet --retry=60 \ | ||
--pidfile ${PIDFILE} \ | ||
--signal=9 | ||
|
||
if service_started "${RC_SVCNAME}"; then | ||
mark_service_stopped "${RC_SVCNAME}" | ||
fi | ||
|
||
eend $? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/bin/bash | ||
# Copyright 1999-2016 Gentoo Foundation | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
# Check for OpenRC and include gentoo-functions if needed | ||
if [ -z "${RC_SVCNAME}" ]; then | ||
source @GENTOO_PORTAGE_EPREFIX@/lib/gentoo/functions.sh | ||
fi | ||
|
||
: ${CATALINA_HOME:=@GENTOO_PORTAGE_EPREFIX@/usr/share/tomcat-@SLOT@} | ||
: ${TOMCATS_BASE:=@GENTOO_PORTAGE_EPREFIX@/var/lib/tomcats/} | ||
: ${CATALINA_TMPDIR:=@GENTOO_PORTAGE_EPREFIX@/var/cache/tomcat-@SLOT@/tmp} | ||
|
||
: ${TOMCAT_START:=start} | ||
|
||
: ${JPDA_TRANSPORT:="dt_socket"} | ||
: ${JPDA_ADDRESS:="8000"} | ||
: ${JPDA_OPTS="-Xdebug -Xrunjdwp:transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=n"} | ||
|
||
if [ -z "${CATALINA_BASE}" ]; then | ||
if [ -z "${CATALINA_INSTANCE}" ]; then | ||
CATALINA_BASE="${CATALINA_HOME}" | ||
else | ||
CATALINA_BASE="${TOMCATS_BASE}${CATALINA_INSTANCE}" | ||
fi | ||
fi | ||
|
||
if [ -z "${CATALINA_WORKDIR}" ]; then | ||
CATALINA_WORKDIR="${CATALINA_TMPDIR}" | ||
fi | ||
|
||
export JAVA_HOME=`java-config ${TOMCAT_JVM:+--select-vm ${TOMCAT_JVM}} --jre-home` | ||
export CLASSPATH="${CATALINA_HOME}/bin/bootstrap.jar:${CATALINA_HOME}/bin/tomcat-juli.jar" | ||
|
||
if [ "$1" = "start" ]; then | ||
if [ ! -e "${CATALINA_TMPDIR}" ]; then | ||
eerror "CATALINA_TMPDIR does not exist. Unable to start tomcat." | ||
eerror "Please see @GENTOO_PORTAGE_EPREFIX@/etc/conf.d/tomcat-@SLOT@ for more information." | ||
exit 1 | ||
fi | ||
|
||
DEPEND=$(java-config --query DEPEND --package tomcat-@SLOT@):${TOMCAT_EXTRA_JARS} | ||
DEPEND=${DEPEND%:} | ||
|
||
GCLASSPATH=$(java-config --with-dependencies --classpath "${DEPEND//:/,}"):${TOMCAT_EXTRA_CLASSPATH} | ||
GCLASSPATH=${GCLASSPATH%:} | ||
|
||
cmd=java args= | ||
if [ "${TOMCAT_START}" = "debug" ] || [ "${TOMCAT_START}" = "-security debug" ] ; then | ||
cmd=jdb | ||
args="${args} -sourcepath ${CATALINA_HOME}/../../jakarta-tomcat-catalina/catalina/src/share" | ||
fi | ||
if [ "${TOMCAT_START}" = "-security debug" ] || [ "${TOMCAT_START}" = "-security start" ]; then | ||
args="${args} -Djava.security.manager" | ||
args="${args} -Djava.security.policy=${CATALINA_BASE}/conf/catalina.policy" | ||
fi | ||
if [ "${TOMCAT_START}" = "jpda start" ] ; then | ||
args="${args} ${JPDA_OPTS}" | ||
fi | ||
if [ -r "${CATALINA_HOME}"/bin/tomcat-juli.jar ]; then | ||
args="${args} -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \ | ||
-Djava.util.logging.config.file=${CATALINA_BASE}/conf/logging.properties" | ||
fi | ||
|
||
cd "${CATALINA_WORKDIR}" | ||
|
||
${JAVA_HOME}/bin/${cmd} \ | ||
${JAVA_OPTS} \ | ||
${JAVA_INSTANCE_OPTS} \ | ||
${args} \ | ||
-Dcatalina.base="${CATALINA_BASE}" \ | ||
-Dcatalina.home="${CATALINA_HOME}" \ | ||
-Djava.io.tmpdir="${CATALINA_TMPDIR}" \ | ||
-Dgentoo.classpath="${GCLASSPATH//:/,}" \ | ||
-classpath "${CLASSPATH}" \ | ||
org.apache.catalina.startup.Bootstrap \ | ||
${CATALINA_OPTS} \ | ||
${TOMCAT_START} | ||
elif [ "$1" = "stop" ]; then | ||
${JAVA_HOME}/bin/java \ | ||
${JAVA_OPTS} \ | ||
${JAVA_INSTANCE_OPTS} \ | ||
-Dcatalina.base="${CATALINA_BASE}" \ | ||
-Dcatalina.home="${CATALINA_HOME}" \ | ||
-Djava.io.tmpdir="${CATALINA_TMPDIR}" \ | ||
-Dgentoo.classpath="" \ | ||
-classpath "${CLASSPATH}" \ | ||
org.apache.catalina.startup.Bootstrap \ | ||
${CATALINA_OPTS} \ | ||
stop | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
d /var/cache/tomcat-@SLOT@/temp 0750 tomcat tomcat - | ||
d /var/cache/tomcat-@SLOT@/work 0750 tomcat tomcat - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Systemd unit file for default tomcat | ||
# | ||
# To create clones of this service: | ||
# DO NOTHING, use tomcat@.service instead. | ||
|
||
[Unit] | ||
Description=Apache Tomcat Web Application Container | ||
After=syslog.target network.target | ||
|
||
[Service] | ||
Type=simple | ||
EnvironmentFile=/etc/conf.d/tomcat-@SLOT@ | ||
ExecStart=/usr/libexec/tomcat/server-@SLOT@ start | ||
ExecStop=/usr/libexec/tomcat/server-@SLOT@ stop | ||
SuccessExitStatus=143 | ||
User=tomcat | ||
Group=tomcat | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
Oops, something went wrong.