Skip to content

Instantly share code, notes, and snippets.

@nerzhul
Created March 23, 2017 15:19
Show Gist options
  • Save nerzhul/3517c7c795d835cd6c1fdf5e80d73fad to your computer and use it in GitHub Desktop.
Save nerzhul/3517c7c795d835cd6c1fdf5e80d73fad to your computer and use it in GitHub Desktop.
tomcat8 systemd unit
{{ ansible_managed | comment }}
[Unit]
Description=Tomcat 8 %I servlet container
After=network.target
[Service]
Type=forking
PIDFile=/var/run/tomcat8_%I.pid
Environment=CATALINA_PID=/var/run/tomcat8_%I.pid
Environment=TOMCAT_TMP_DIR=/var/lib/tomcat8_%I/tmp
Environment=TOMCAT_LOG_DIR=/var/log/tomcat8_%I
Environment=TOMCAT_JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-x64
Environment=CATALINA_HOME=/usr/share/tomcat8
Environment=CATALINA_BASE=/var/lib/tomcat8_%I
# Default value, can be override by EnvironmentFile
Environment=TOMCAT_USER=tomcat8
Environment=TOMCAT_HEAPDUMP_PATH=/tmp
Environment=TOMCAT_JMX_OPTS=
EnvironmentFile=/etc/default/tomcat8_%I
LimitNOFILE=4096
ExecStart=/usr/bin/jsvc \
-Dcatalina.home=${CATALINA_HOME} \
-Dcatalina.base=${CATALINA_BASE} \
-Djava.io.tmpdir=${TOMCAT_TMP_DIR} \
-Djava.library.path=${PATH}:/usr/lib/x86_64-linux-gnu \
-Djava.awt.headless=true \
-Xloggc:${TOMCAT_LOG_DIR}/gc.log \
-XX:+PrintGCDateStamps \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath=${TOMCAT_HEAPDUMP_PATH} \
-cp /usr/share/java/commons-daemon.jar:/usr/share/java/eclipse-ecj.jar:${CATALINA_HOME}/bin/bootstrap.jar:${CATALINA_HOME}/bin/tomcat-juli.jar \
-user ${TOMCAT_USER} \
-java-home ${TOMCAT_JAVA_HOME} \
-pidfile ${CATALINA_PID} \
-errfile ${TOMCAT_LOG_DIR}/catalina.err \
-outfile ${TOMCAT_LOG_DIR}/catalina.out \
$TOMCAT_JMX_OPTS \
$CATALINA_OPTS \
org.apache.catalina.startup.Bootstrap
ExecStop=/usr/bin/jsvc \
-pidfile ${CATALINA_PID} \
-stop \
org.apache.catalina.startup.Bootstrap
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment