linuxtomcatmicrostrategy

Tomcat Start on Reboot: init.d script unsuccessful


I need to have tomcat start after a reboot of the linux OS. I cannot get init.d to function properly through reboot.

OS and Versions:

JRE: 1.8.0
JAVA: 1.8.0
Tomcat:  8.5.34
Linux:  Amazon Linux 2

****ALL STEPS COMPLETED AS ROOT

TOMCAT Deployment Configuration:

1)  Install tomcat 8.5.34 using a tar.gz gzip file
2)  configure /{$TOMCAT}/conf/server.xml to use 443 connectors
3)  Deploy MicroStrategy application through deploying a .war file on restart
4)  configure SSL keys using Java Key Store
5)  configure microstrategy webapp for SAML authentication using PING

init.d Script Deployment Configuration

Note: I have tried various scripts through /etc/init.d/tomcat and the chkconfig utility.
1) Create tomcat using vi 2) Insert script (I have tried numerous scripts, but this one seems to be the clostest to exactly what I need and the most explicit) 3) chmod 755 /etc/init.d/tomcat 4) chkconfig --add tomcat 5) chkconfig --level 2345 tomcat on (This command is not successful) 6) chkconfig --list tomcat (returns tomcat 0:off 1:off 2:off 3:on 4:on 5:on 6:off)

Testing of this script is successful:

./etc/init.d/tomcat start
./etc/init.d/tomcat stop
./etc/init.d/tomcat restart 

Confirmed that chkconfig created the links:

/etc/rc1.d  K20tomcat
/etc/rc2.d  K20tomcat
/etc/rc3.d  S82tomcat
/etc/rc4.d  S82tomcat
/etc/rc5.d  S82tomcat
/etc/rc6.d  K20tomcat

Script File for Tomcat

#!/bin/sh
#
# chkconfig: 345 82 20
#
# description:  Tomcat Service


JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
JRE_HOME=/usr/lib/jvm/jre-1.8.0-openjdk
CATALINA_HOME=/opt/apache-tomcat-8.5.34
export JAVA_HOME JRE_HOME CATALINA_HOME
case $1 in
start)
cd $CATALINA_HOME/bin
./startup.sh
;;
stop)
cd $CATALINA_HOME/bin
./shutdown.sh
;;
restart)
cd $CATALINA_HOME/bin
./shutdown.sh    
./startup.sh
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0

Expectations

I expect the base URL at {$TOMCAT}/webapps/ROOT to be accessible from the Public URL pointing to this device following a reboot. The tomcat services remain in a stopped state after reboot.

Any suggestions?


Solution

  • Amazon Linux 2 uses systemd service manager which should be backwards compatible with systemv init scripts provided that systemd-sysv-generator is executed to generate service units out of /etc/init.d scripts (not recommended in your case I think). Since you are writing the script yourself it is recommended that you write a proper service unit.
    It's probable that such *.service file is already present on the tar.gz used to install tomcat.