Skip to content

Instantly share code, notes, and snippets.

@mattocchi
Last active April 17, 2019 15:37
Show Gist options
  • Save mattocchi/778cb9f3caede1e068c39bd060437322 to your computer and use it in GitHub Desktop.
Save mattocchi/778cb9f3caede1e068c39bd060437322 to your computer and use it in GitHub Desktop.
systemd unit service user vanilla tomcat
# sudo cp tomcat.service /etc/systemd/system -i
# sudo nano /etc/systemd/system/tomcat.service
# sudo systemctl daemon-reload
# sudo systemctl enable tomcat
# sudo systemctl start tomcat
# systemctl status tomcat
# sudo systemctl restart tomcat
[Unit]
Description=tomcat
After=syslog.target network.target
Requires=network.target
[Service]
Environment="JAVA_HOME=/home/ubuntu/jdk8u192-b12-jre"
Environment="CATALINA_BASE=/home/ubuntu/apache-tomcat-8.5.24"
Environment="CATALINA_HOME=/home/ubuntu/apache-tomcat-8.5.24"
Environment="CATALINA_PID=/home/ubuntu/apache-tomcat-8.5.24/bin/catalina.pid"
# you can use setenv.sh instead
#Environment="CATALINA_OPTS=-Xms256m -Xmx512m -XX:PermSize=32m -XX:MaxPermSize=256m -Xss2m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled"
# customize ports for multiple tomcat instances
#Environment="JAVA_OPTS=-Dhttp.port=8082 -Dhttps.port=8445 -Dajp.port=8011 -Dshutdown.port=8007"
Type=forking
User=ubuntu
PIDFile=/home/ubuntu/apache-tomcat-8.5.24/bin/catalina.pid
WorkingDirectory=/home/ubuntu/apache-tomcat-8.5.24
ExecStart=/home/ubuntu/apache-tomcat-8.5.24/bin/startup.sh
ExecStop=/home/ubuntu/apache-tomcat-8.5.24/bin/shutdown.sh
Restart=always
RestartSec=20
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment