I am at the moment establishing a RHEL 7.Eight tomcat service and I am having hassle with the
the next file was arrange on /and so on/init.d/tomcat:
#!/bin/bash # # # chkconfig: 2345 20 80 # description: Begin up the Tomcat servlet engine. # Supply operate library. . /and so on/init.d/capabilities RETVAL=$? CATALINA_HOME="<tomcat 9 folder location>" JAVA_HOME="/usr/java/jdk1.8.0_251" case "$1" in begin) if [ -f $CATALINA_HOME/bin/startup.sh ]; then echo $"Beginning Tomcat" /bin/su saveweb -c "JAVA_HOME=$JAVA_HOME $CATALINA_HOME/bin/startup.sh" fi ;; cease) if [ -f $CATALINA_HOME/bin/shutdown.sh ]; then echo $"Stopping Tomcat" /bin/su saveweb -c "JAVA_HOME=$JAVA_HOME $CATALINA_HOME/bin/shutdown.sh 15 -force" fi ;; *) echo $"Utilization: $0 cease" exit 1 ;; esac exit $RETVAL
And that is the /run/systemd/generator.late/tomcat.service file:
# Robotically generated by systemd-sysv-generator [Unit] Documentation=man:systemd-sysv-generator(8) SourcePath=/and so on/rc.d/init.d/tomcat Description=SYSV: Begin up the Tomcat servlet engine. Earlier than=runlevel2.goal Earlier than=runlevel3.goal Earlier than=runlevel4.goal Earlier than=runlevel5.goal Earlier than=rhnsd.service After=network-online.goal After=community.service [Service] Sort=forking Restart=no TimeoutSec=5min IgnoreSIGPIPE=no KillMode=course of GuessMainPID=no RemainAfterExit=sure ExecStart=/and so on/rc.d/init.d/tomcat begin ExecStop=/and so on/rc.d/init.d/tomcat cease
(I will be sincere right here, I do not know the way or who generated these information. I am working with what was given to me)
This works high-quality for many use instances (beginning service on system boot, utilizing
systemctl begin tomcat and
systemctl cease tomcat and so on). We additionally set tomcat in a manner that its setenv.sh defines a
CATALINA_PID variable, in order that beginning/stopping the tomcat server straight by its scripts or by
systemctl will work.
That is all as a result of some customers may, because of human error, begin the tomcat service twice. We positively don’t desire two tomcat situations.
So whereas testing it out, the whole lot gave the impression to be working correctly. After I use
systemctl begin tomcat twice, solely the primary occasion of the tomcat service will probably be up – as anticipated.
Nonetheless, it was identified that if we somebody makes use of
service tomcat begin whereas the earlier service was on-line, the
service program will first cease after which begin the service.
# this works high-quality! systemctl begin tomcat systemctl begin tomcat # effectivelly ignored, possibly some log saying that there was a earlier occasion on-line. Good!
service begin tomcat service begin tomcat # logs present that "cease" was referred to as after which the service was began once more. not good.
I am tremendous confused as a result of in all places I seemed says that
service is only a wrapper for
systemctl. So what offers? Why does
service have a special conduct than
systemctl on this scenario, and what must be performed to repair it in order that they’re constant?
Any assistance is welcome.