glejo03

CA Layer 7 - API PORTAL – add tomcat service start at a boot time

Blog Post created by glejo03 Employee on Apr 3, 2015
  • Connect to the server where you have API Portal installed, log as root
  • Create script “tomcat” in /etc/init.d, and assure correct rights

[root@apiportal3 init.d]# touch tomcat

[root@apiportal3 init.d]# chmod 755 tomcat

  • Put following script body into the tomcat file and save

[root@apiportal3 init.d]# vi tomcat

#!/bin/bash

#@author:  josef.glemba@ca.com - 2.4.2015

#@purpose: add tomcat start during boot

# --line below allows support for chkconfig--

# chkconfig: 235 20 80

 

# Source function library

. /etc/init.d/functions

 

RETVALUE=$?

 

CATALINA_HOME="/opt/Deployments/lrs/server"

 

case "$1" in

start)

if [ -f $CATALINA_HOME/bin/catalina.sh ];

          then

             $CATALINA_HOME/bin/catalina.sh start

fi

;;

stop)

if [ -f $CATALINA_HOME/bin/catalina.sh ];

          then

             $CATALINA_HOME/bin/catalina.sh stop

fi

;;

*)

echo $"Usage: $0 {start|stop}"

exit 1

;;

esac

 

#exit value depends on running the script successfully/nonsuccessfully

exit $RETVALUE

  • Create symbolic link in /etc/rc5.d (S71tomcat -> ../init.d/tomcat)

[root@apiportal3 rc5.d]# ln -s /etc/init.d/tomcat S71tomcat

  • Add service to management

[root@apiportal3 rc5.d]#  chkconfig --add tomcat

  • Check service

[root@apiportal3 rc5.d]# chkconfig --list tomcat

tomcat          0:off   1:off 2:on    3:on    4:off 5:on    6:off

  • Reboot the machine and check if tomcat is running (Proces: ps –edf | grep catalina | or port 37085 for example)

root      1483 1 12 11:31 ?        00:02:45 /opt/jdk/bin/java -Djava.util.logging.config.file=/opt/Deployments/lrs/server/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -XX:MaxPermSize=256m -Xmx2048M -Xms256M -Dcom.thelevel.LOGGING=on -Dcom.thelevel.LOGGING.noFormat=on -Dcom.thelevel.cacheconfig=cacheconfig.xml -Djava.library.path=/usr/local/lib -Djavax.net.ssl.trustStore=/etc/java/keystore -Djava.endorsed.dirs=/opt/Deployments/lrs/server/endorsed -classpath /opt/Deployments/lrs/server/bin/bootstrap.jar -Dcatalina.base=/opt/Deployments/lrs/server -Dcatalina.home=/opt/Deployments/lrs/server -Djava.io.tmpdir=/opt/Deployments/lrs/server/temp org.apache.catalina.startup.Bootstrap start

Outcomes