I installed Tomcat 8.5 and I am able to start it successfully manually, for example:
su tomcat startup.sh
works properly and tomcat is able to serve on port 8080.
I need to automate the startup, so I created the file /etc/systemd/system/tomcat-prod.service:
[Unit]
Description=Tomcat 8.5 servlet container - Production
After=network.target
[Service]
Type=forking
ExecStart=/opt/appservers/production/apache-tomcat-8.5.37/bin/startup.sh
ExecStop=/opt/appservers/production/apache-tomcat-8.5.37/bin/shutdown.sh
User=tomcat
Group=tomcat
[Install]
WantedBy=multi-user.target
The file is bare on purpose, all my env variables are in setenv.sh. I tried running it using:
# systemctl daemon-reload
# systemctl start tomcat-prod
For some reason above results in Tomcat exiting just after startup. I get no log anywhere that explains why. Tomcat creates an empty catalina.out file on startup and systemctl status tomcat-prod gives only the following:
tomcat-prod.service - Tomcat 8.5 servlet container - Production Loaded: loaded (/etc/systemd/system/tomcat-prod.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Fri 2019-01-04 08:08:27 UTC; 3s ago Process: 3583 ExecStop=/opt/appservers/production/apache-tomcat-8.5.37/shutdown.sh (code=exited, status=203/EXEC) Process: 3569 ExecStart=/opt/appservers/production/apache-tomcat-8.5.37/bin/startup.sh (code=exited, status=0/SUCCESS) Main PID: 3581 (code=exited, status=0/SUCCESS)
Jan 04 08:08:27 *.net startup.sh[3569]: Existing PID file found during start. Jan 04 08:08:27 *.net startup.sh[3569]: Removing/clearing stale PID file.
Can someone point me in the right direction?
shutdown.sh
file is also inbin
directory, if you haven't moved it.