[Unit]
Description=Apache TomEE
After=network.target
[Service]
User=<user to run as>
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment=CATALINA_PID=/opt/tomee/temp/tomee.pid
Environment=CATALINA_HOME=/opt/tomee
Environment=CATALINA_BASE=/opt/tomee
Environment=CATALINA_OPTS='-server'
Environment=JAVA_OPTS='-Djava.awt.headless=true'
ExecStart=/opt/tomee/bin/startup.sh
ExecStop=/opt/tomee/bin/shutdown.sh
KillSignal=SIGCONT
[Install]
WantedBy=multi-user.target
Linux Service
Depending on your flavour of Linux, there are likely a few different ways you can run TomEE as a service. This page demonstrates running as a service with systemd, and has been tested with RedHat Enterprise Linux.
Create a file /etc/systemd/system/tomee.service with the following content:
The file above assumes TomEE is extracted to /opt/tomee, and that JAVA_HOME is at /usr/lib/jvm/jre - adjust these to match your installation.
Once done, run sudo systemctl daemon-reload so systemd is aware of the new service.
You should now be able to use the following commands to control the TomEE service:
-
sudo systemctl start tomee(to start TomEE) -
sudo systemctl stop tomee(to stop TomEE) -
sudo systemctl status tomee(to check the status of the TomEE service)