...
Code Block |
---|
sudo vi /etc/systemd/system/tomcat.service |
and And then paste the following into it:script into the file, making sure that the script is adjusted so that:
- JAVA_HOME points to the version of java that you want to use
- the memory settings (-Xms and -Xmx) on the line for CATALINE_OPTS are set as needed (this example assumes you are allocating 8GB of memory to tomcat)
Code Block |
---|
[Unit] Description=Apache Tomcat Web Application Container After=network.target [Service] Type=forking Environment=JAVA_HOME=/opt/jdk/jdk1.8.0_85/jre Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid Environment=CATALINA_HOME=/opt/tomcat Environment=CATALINA_BASE=/opt/tomcat Environment='CATALINA_OPTS=-Xms1000MXms8096M -Xmx2000MXmx8096M -server -verbose:gc' Environment='JAVA_OPTS=-Djava.awt.headless=true' ExecStart=/opt/tomcat/bin/startup.sh ExecStop=/opt/tomcat/bin/shutdown.sh WorkingDirectory=/opt/tomcat User=tomcat Group=tomcat UMask=0007 RestartSec=10 Restart=always [Install] WantedBy=multi-user.target |
Before saving this,
...
Now enable, then start the service:
...