| Server IP : 104.21.21.239 / Your IP : 216.73.216.76 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /opt/lucee/ |
Upload File : |
#!/bin/bash
# chkconfig: 345 22 78
# description: Tomcat/Lucee Control Script
### BEGIN INIT INFO
# Provides: lucee_ctl
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0
# Short-Description: Tomcat/Lucee Control Script
# Description: This is the control script that starts and stops Tomcat which contains a global install of the Lucee servlet.
### END INIT INFO
# switch the subshell to the tomcat directory so that any relative
# paths specified in any configs are interpreted from this directory.
cd /opt/lucee/tomcat/
# set base params for subshell
CATALINA_BASE=/opt/lucee/tomcat; export CATALINA_BASE
CATALINA_HOME=/opt/lucee/tomcat; export CATALINA_HOME
CATALINA_PID=/opt/lucee/tomcat/work/tomcat.pid; export CATALINA_PID
CATALINA_TMPDIR=/opt/lucee/tomcat/temp; export CATALINA_TMPDIR
JRE_HOME=/usr/lib/jvm/java-21-amazon-corretto.x86_64; export JRE_HOME
JAVA_HOME=/usr/lib/jvm/java-21-amazon-corretto.x86_64; export JAVA_HOME
TOMCAT_OWNER=root; export TOMCAT_OWNER
findpid() {
PID_FOUND=0
if [ -f "$CATALINA_PID" ] ; then
PIDNUMBER=`cat "$CATALINA_PID"`
TEST_RUNNING=`ps -p ${PIDNUMBER} | grep ${PIDNUMBER} | grep java`
if [ ! -z "${TEST_RUNNING}" ]; then
# PID is found and running
PID_FOUND=1
fi
fi
}
start() {
echo -n " * Starting Lucee: "
findpid
# only actually run the start command if the PID isn't found
if [ $PID_FOUND -eq 0 ] ; then
su -p -s /bin/sh $TOMCAT_OWNER $CATALINA_HOME/bin/startup.sh
COUNT=0
while [ $COUNT -lt 3 ] ; do
COUNT=$(($COUNT+1))
echo -n ". "
sleep 1
done
echo "[DONE]"
echo "--------------------------------------------------------"
echo "It may take a few moments for Lucee to start processing"
echo "CFML templates. This is normal."
echo "--------------------------------------------------------"
else
echo "[ALREADY RUNNING]"
fi
}
stop() {
echo -n " * Shutting down Lucee: "
findpid
if [ $PID_FOUND -eq 1 ] ; then
su -p -s /bin/sh $TOMCAT_OWNER $CATALINA_HOME/bin/shutdown.sh 10 &
COUNT=0
while [ $PID_FOUND -eq 1 ] ; do
findpid
COUNT=$(($COUNT+1))
if [ $COUNT -gt 10 ] ; then
break
fi
echo -n ". "
# pause while we wait to try again
sleep 1
done
findpid
if [ $PID_FOUND -eq 1 ] ; then
echo "[FAIL]"
echo " * The Tomcat/Lucee process is not responding. Forcing shutdown..."
forcequit
else
echo "[DONE]"
fi
elif [ ! -f $CATALINA_PID ] ; then
# if the pid file doesn't exist, just say "okay"
echo "[DONE]"
else
echo "[Cannot locate Tomcat PID (`cat $CATALINA_PID`) ]"
echo "--------------------------------------------------------"
echo "If the Tomcat process is still running, either kill the"
echo "PID directly or use the 'killall' command."
echo "IE: # killall java"
echo "--------------------------------------------------------"
fi
}
forcequit() {
echo -n " * Forcing Lucee Shutdown: "
findpid
if [ $PID_FOUND -eq 1 ] ; then
# if the PID is still running, force it to die
# su -p -s /bin/sh $TOMCAT_OWNER /bin/shutdown.sh -force
kill -9 $PIDNUMBER
rm -rf $CATALINA_PID
echo "[DONE]"
else
# there is no PID, tell the user.
echo "[FAIL]"
echo "--------------------------------------------------------"
echo "No Tomcat PID found. If the Tomcat process is still"
echo "active under a different PID, please kill it manually."
echo "--------------------------------------------------------"
fi
}
status() {
findpid
if [ $PID_FOUND -eq 1 ] ; then
echo " * Lucee/Tomcat is running (PID: $PIDNUMBER)"
else
echo " * PID not found."
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
forcequit)
forcequit
;;
restart)
stop
sleep 5
start
;;
status)
status
;;
*)
echo " * Usage: $0 {start|stop|restart|forcequit|status}"
exit 1
;;
esac
exit 0