从上篇文章中可以看出,tomcat启动最后靠的是catalina.sh,那么现在我们分析一下这个脚本。
首先一段跟在startup.sh中的逻辑是一样的,都是找到catalina.sh脚本所在的目录:
cygwin=false
os400=false
darwin=false
case "`uname`" in
CYGWIN*) cygwin=true;;
OS400*) os400=true;;
Darwin*) darwin=true;;
esac
# resolve links - $0 may be a softlink
PRG="$0"
while [ -h "$PRG" ]; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`/"$link"
fi
done
# Get standard environment variables
PRGDIR=`dirname "$PRG"`
然后设置tomcat的主目录,也就是安装目录:
# Only set CATALINA_HOME if not already set
[ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
-z选项表示参数(一般是字符串)的长度为0。如果其值为真,表示环境变量CATALINA_HOME的值尚未设置,于是执行“&&”后面的部分。在shell中,“&&”并不仅仅表示逻辑判断and,而且是当其前半部分为真时执行后半部分的命令。cd "$PRGDIR/.."将跳转到bin所在的目录,也就是tomcat的安装目录。pwd命令显示这个目录的名字,然后这个值会被赋给CATALINA_HOME。这里注意一下“;”的用途,它和“&&”类似,也起到连接命令的作用,只是它不做逻辑判断,无论前面的命令执行成功与否,后半部分都会执行。
接着是设置classpath:
# Ensure that any user defined CLASSPATH variables are not used on startup,
# but allow them to be specified in setenv.sh, in rare case when it is needed.
CLASSPATH=
它被设置成了空值,而且是故意的,原因我们会在后面分析。
SETENVPATH="${CATALINA_BASE:-$CATALINA_HOME}"
if [ -r "$SETENVPATH/bin/setenv.sh" ]; then
. "$SETENVPATH/bin/setenv.sh"
elif [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
. "$CATALINA_HOME/bin/setenv.sh"
fi
这段代码是为了执行setenv.sh脚本。首先要注意的是花括号中变量用法:${var:-string},若变量var为空,则用在命令行中用变量string来替换${var:-string},否则变量var不为空时,则用变量var的值来替换${var:-string}。然后是“点号 + 空格 + 脚本”这种执行脚本的方式,这时点号本身就变成了一个命令,作用和source类似,不再多说。
(略去两段无关代码)
然后执行setclasspath.sh脚本:
# Get standard Java environment variables
if $os400; then
# -r will Only work on the os400 if the files are:
# 1. owned by the user
# 2. owned by the PRIMARY group of the user
# this will not work if the user belongs in secondary groups
BASEDIR="$CATALINA_HOME"
. "$CATALINA_HOME"/bin/setclasspath.sh
else
if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then
BASEDIR="$CATALINA_HOME"
. "$CATALINA_HOME"/bin/setclasspath.sh
else
echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh"
echo "This file is needed to run this program"
exit 1
fi
fi
这个脚本中设置了一系列跟java相关的环境变量。
接着就是向classpath中添加了jar包:
# Add on extra jar files to CLASSPATH
if [ ! -z "$CLASSPATH" ] ; then
CLASSPATH="$CLASSPATH":
fi
CLASSPATH="$CLASSPATH""$CATALINA_HOME"/bin/bootstrap.jar
这个jar包是tomcat的启动jar包,main方法就是在这个jar包中。
下面来到本篇的重点之一了,CATALINA_BASE:
if [ -z "$CATALINA_BASE" ] ; then
CATALINA_BASE="$CATALINA_HOME"
fi
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
fi
if [ -z "$CATALINA_TMPDIR" ] ; then
# Define the java.io.tmpdir to use for Catalina
CATALINA_TMPDIR="$CATALINA_BASE"/temp
fi
如果没有设置CATALINA_BASE这个环境变量,那么就把CATALINA_HOME的值给他。这两者有啥区别呢?后者显然指的就是安装目录,也就是bin目录所在的目录。我们知道,同一个tomcat实例上可以运行多个web应用,于是当tomcat起停的时候,这几个web应用都会受到影响。另外,这几个web应用还会共享同一个tomcat的配置(就是tomcat的server.xml文件)、工作目录work、日志记录等。有些时候,这时很不方便的,我们需要单独起停某个应用,或者需要对其使用的tomcat环境进行个性化配置,这势必不能和其他应用共享很多东西。一句话,要分家。
具体的办法就是,新建一个目录,把安装目录中的东西copy过来。当然分家也不能分的太彻底,至少bin和lib目录还是可以共享的,没有必要再复制一份,但是其他的所有目录却要都复制过来,然后把这个大本营设置为CATALINA_BASE。有一个问题就是,如果系统中存在多个这样的应用(或者tomcat实例),那么CATALINA_BASE到底该设成哪个值?由于这是一个公共的变量,所以只能每个应用启动的时候都重新设置一次。
从这里就可以看出,CATALINA_HOME的值可以在/etc/profile,~/.bashrc等文件中设置,但CATALINA_BASE却不可以在这些文件中设置。我还有一个担心就是,当第二个应用更改了CATALINA_BASE的值会不会影响第一个已经起来的应用?我想了很久,觉得不会。因为,这个变量只会在tomcat启动的时候用到,起来之后其实就不需要了。
之后的log和temp目录都是基于CATALINA_BASE设置的。
# Add tomcat-juli.jar to classpath
# tomcat-juli.jar can be over-ridden per instance
if [ -r "$CATALINA_BASE/bin/tomcat-juli.jar" ] ; then
CLASSPATH=$CLASSPATH:$CATALINA_BASE/bin/tomcat-juli.jar
else
CLASSPATH=$CLASSPATH:$CATALINA_HOME/bin/tomcat-juli.jar
fi
这是在向classpath中增加日志记录所需要的jar包。
(略去几段无关代码)
# Bugzilla 37848: only output this if we have a TTY
if [ $have_tty -eq 1 ]; then
echo "Using CATALINA_BASE: $CATALINA_BASE"
echo "Using CATALINA_HOME: $CATALINA_HOME"
echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
if [ "$1" = "debug" ] ; then
echo "Using JAVA_HOME: $JAVA_HOME"
else
echo "Using JRE_HOME: $JRE_HOME"
fi
echo "Using CLASSPATH: $CLASSPATH"
if [ ! -z "$CATALINA_PID" ]; then
echo "Using CATALINA_PID: $CATALINA_PID"
fi
fi
这里出现了执行startup.sh脚本时熟悉的几句话
接下里就是正式的启动了:
if [ "$1" = "jpda" ] ; then
...
fi
if [ "$1" = "debug" ] ; then
...
elif [ "$1" = "run" ]; then
...
elif [ "$1" = "start" ] ; then
...
elif [ "$1" = "stop" ] ; then
...
elif [ "$1" = "configtest" ] ; then
...
elif [ "$1" = "version" ] ; then
...
else
echo "Usage: catalina.sh ( commands ... )"
echo "commands:"
if $os400; then
echo " debug Start Catalina in a debugger (not available on OS400)"
echo " debug -security Debug Catalina with a security manager (not available on OS400)"
else
echo " debug Start Catalina in a debugger"
echo " debug -security Debug Catalina with a security manager"
fi
echo " jpda start Start Catalina under JPDA debugger"
echo " run Start Catalina in the current window"
echo " run -security Start in the current window with security manager"
echo " start Start Catalina in a separate window"
echo " start -security Start in a separate window with security manager"
echo " stop Stop Catalina, waiting up to 5 seconds for the process to end"
echo " stop n Stop Catalina, waiting up to n seconds for the process to end"
echo " stop -force Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running"
echo " stop n -force Stop Catalina, wait up to n seconds and then use kill -KILL if still running"
echo " version What version of tomcat are you running?"
echo "Note: Waiting for the process to end and use of the -force option require that \$CATALINA_PID is defined"
exit 1
fi
可见,传递给catalina.sh脚本的第一个参数有jpda run start stop configtest version共6个,若第一个参数不是其中之一,就会给出最后的提示。很显然,shutdown.sh脚本肯定也是调用了catalina.sh并传给它stop作为第一个参数。限于篇幅,这里只分析第一个参数是start的情况。
...
elif [ "$1" = "start" ] ; then
if [ ! -z "$CATALINA_PID" ]; then
if [ -f "$CATALINA_PID" ]; then
if [ -s "$CATALINA_PID" ]; then
echo "Existing PID file found during start."
if [ -r "$CATALINA_PID" ]; then
PID=`cat "$CATALINA_PID"`
ps -p $PID >/dev/null 2>&1
if [ $? -eq 0 ] ; then
echo "Tomcat appears to still be running with PID $PID. Start aborted."
exit 1
else
echo "Removing/clearing stale PID file."
rm -f "$CATALINA_PID" >/dev/null 2>&1
if [ $? != 0 ]; then
if [ -w "$CATALINA_PID" ]; then
cat /dev/null > "$CATALINA_PID"
else
echo "Unable to remove or clear stale PID file. Start aborted."
exit 1
fi
fi
fi
else
echo "Unable to read PID file. Start aborted."
exit 1
fi
else
rm -f "$CATALINA_PID" >/dev/null 2>&1
if [ $? != 0 ]; then
if [ ! -w "$CATALINA_PID" ]; then
echo "Unable to remove or write to empty PID file. Start aborted."
exit 1
fi
fi
fi
fi
fi
shift
touch "$CATALINA_OUT"
if [ "$1" = "-security" ] ; then
if [ $have_tty -eq 1 ]; then
echo "Using Security Manager"
fi
shift
eval \"$_RUNJAVA\" \"$LOGGING_CONFIG\" $JAVA_OPTS $CATALINA_OPTS \
-Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
-Djava.security.manager \
-Djava.security.policy==\"$CATALINA_BASE/conf/catalina.policy\" \
-Dcatalina.base=\"$CATALINA_BASE\" \
-Dcatalina.home=\"$CATALINA_HOME\" \
-Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
else
eval \"$_RUNJAVA\" \"$LOGGING_CONFIG\" $JAVA_OPTS $CATALINA_OPTS \
-Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
-Dcatalina.base=\"$CATALINA_BASE\" \
-Dcatalina.home=\"$CATALINA_HOME\" \
-Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
fi
if [ ! -z "$CATALINA_PID" ]; then
echo $! > "$CATALINA_PID"
fi
elif [ "$1" = "stop" ] ; then
...
首先是一堆if语句,用于判断CATALINA_PID变量,这些代码暂时可以忽略,因为:我没有在脚本中发现对这个变量进行赋值的语句;也没有触发过与之有关的错误。所以往下看,shift命令干掉了刚刚的start参数,使得原来的第二个参数变成了第一个;然后touch了一下log文件。
由于很少使用-security选项,所以直接跳到下一部分:
eval \"$_RUNJAVA\" \"$LOGGING_CONFIG\" $JAVA_OPTS $CATALINA_OPTS \
-Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
-Dcatalina.base=\"$CATALINA_BASE\" \
-Dcatalina.home=\"$CATALINA_HOME\" \
-Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
eval后面的一堆变量是在setclasspath.sh脚本中定义的,然后是一堆java选项,紧接着就是主函数登场了org.apache.catalina.startup.Bootstrap,并传入参数"$@"和start,最后一句是一个重定向以及在背景中执行。
首先一段跟在startup.sh中的逻辑是一样的,都是找到catalina.sh脚本所在的目录:
cygwin=false
os400=false
darwin=false
case "`uname`" in
CYGWIN*) cygwin=true;;
OS400*) os400=true;;
Darwin*) darwin=true;;
esac
# resolve links - $0 may be a softlink
PRG="$0"
while [ -h "$PRG" ]; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`/"$link"
fi
done
# Get standard environment variables
PRGDIR=`dirname "$PRG"`
然后设置tomcat的主目录,也就是安装目录:
# Only set CATALINA_HOME if not already set
[ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
-z选项表示参数(一般是字符串)的长度为0。如果其值为真,表示环境变量CATALINA_HOME的值尚未设置,于是执行“&&”后面的部分。在shell中,“&&”并不仅仅表示逻辑判断and,而且是当其前半部分为真时执行后半部分的命令。cd "$PRGDIR/.."将跳转到bin所在的目录,也就是tomcat的安装目录。pwd命令显示这个目录的名字,然后这个值会被赋给CATALINA_HOME。这里注意一下“;”的用途,它和“&&”类似,也起到连接命令的作用,只是它不做逻辑判断,无论前面的命令执行成功与否,后半部分都会执行。
接着是设置classpath:
# Ensure that any user defined CLASSPATH variables are not used on startup,
# but allow them to be specified in setenv.sh, in rare case when it is needed.
CLASSPATH=
它被设置成了空值,而且是故意的,原因我们会在后面分析。
SETENVPATH="${CATALINA_BASE:-$CATALINA_HOME}"
if [ -r "$SETENVPATH/bin/setenv.sh" ]; then
. "$SETENVPATH/bin/setenv.sh"
elif [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
. "$CATALINA_HOME/bin/setenv.sh"
fi
这段代码是为了执行setenv.sh脚本。首先要注意的是花括号中变量用法:${var:-string},若变量var为空,则用在命令行中用变量string来替换${var:-string},否则变量var不为空时,则用变量var的值来替换${var:-string}。然后是“点号 + 空格 + 脚本”这种执行脚本的方式,这时点号本身就变成了一个命令,作用和source类似,不再多说。
(略去两段无关代码)
然后执行setclasspath.sh脚本:
# Get standard Java environment variables
if $os400; then
# -r will Only work on the os400 if the files are:
# 1. owned by the user
# 2. owned by the PRIMARY group of the user
# this will not work if the user belongs in secondary groups
BASEDIR="$CATALINA_HOME"
. "$CATALINA_HOME"/bin/setclasspath.sh
else
if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then
BASEDIR="$CATALINA_HOME"
. "$CATALINA_HOME"/bin/setclasspath.sh
else
echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh"
echo "This file is needed to run this program"
exit 1
fi
fi
这个脚本中设置了一系列跟java相关的环境变量。
接着就是向classpath中添加了jar包:
# Add on extra jar files to CLASSPATH
if [ ! -z "$CLASSPATH" ] ; then
CLASSPATH="$CLASSPATH":
fi
CLASSPATH="$CLASSPATH""$CATALINA_HOME"/bin/bootstrap.jar
这个jar包是tomcat的启动jar包,main方法就是在这个jar包中。
下面来到本篇的重点之一了,CATALINA_BASE:
if [ -z "$CATALINA_BASE" ] ; then
CATALINA_BASE="$CATALINA_HOME"
fi
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
fi
if [ -z "$CATALINA_TMPDIR" ] ; then
# Define the java.io.tmpdir to use for Catalina
CATALINA_TMPDIR="$CATALINA_BASE"/temp
fi
如果没有设置CATALINA_BASE这个环境变量,那么就把CATALINA_HOME的值给他。这两者有啥区别呢?后者显然指的就是安装目录,也就是bin目录所在的目录。我们知道,同一个tomcat实例上可以运行多个web应用,于是当tomcat起停的时候,这几个web应用都会受到影响。另外,这几个web应用还会共享同一个tomcat的配置(就是tomcat的server.xml文件)、工作目录work、日志记录等。有些时候,这时很不方便的,我们需要单独起停某个应用,或者需要对其使用的tomcat环境进行个性化配置,这势必不能和其他应用共享很多东西。一句话,要分家。
具体的办法就是,新建一个目录,把安装目录中的东西copy过来。当然分家也不能分的太彻底,至少bin和lib目录还是可以共享的,没有必要再复制一份,但是其他的所有目录却要都复制过来,然后把这个大本营设置为CATALINA_BASE。有一个问题就是,如果系统中存在多个这样的应用(或者tomcat实例),那么CATALINA_BASE到底该设成哪个值?由于这是一个公共的变量,所以只能每个应用启动的时候都重新设置一次。
从这里就可以看出,CATALINA_HOME的值可以在/etc/profile,~/.bashrc等文件中设置,但CATALINA_BASE却不可以在这些文件中设置。我还有一个担心就是,当第二个应用更改了CATALINA_BASE的值会不会影响第一个已经起来的应用?我想了很久,觉得不会。因为,这个变量只会在tomcat启动的时候用到,起来之后其实就不需要了。
之后的log和temp目录都是基于CATALINA_BASE设置的。
# Add tomcat-juli.jar to classpath
# tomcat-juli.jar can be over-ridden per instance
if [ -r "$CATALINA_BASE/bin/tomcat-juli.jar" ] ; then
CLASSPATH=$CLASSPATH:$CATALINA_BASE/bin/tomcat-juli.jar
else
CLASSPATH=$CLASSPATH:$CATALINA_HOME/bin/tomcat-juli.jar
fi
这是在向classpath中增加日志记录所需要的jar包。
(略去几段无关代码)
# Bugzilla 37848: only output this if we have a TTY
if [ $have_tty -eq 1 ]; then
echo "Using CATALINA_BASE: $CATALINA_BASE"
echo "Using CATALINA_HOME: $CATALINA_HOME"
echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
if [ "$1" = "debug" ] ; then
echo "Using JAVA_HOME: $JAVA_HOME"
else
echo "Using JRE_HOME: $JRE_HOME"
fi
echo "Using CLASSPATH: $CLASSPATH"
if [ ! -z "$CATALINA_PID" ]; then
echo "Using CATALINA_PID: $CATALINA_PID"
fi
fi
这里出现了执行startup.sh脚本时熟悉的几句话
接下里就是正式的启动了:
if [ "$1" = "jpda" ] ; then
...
fi
if [ "$1" = "debug" ] ; then
...
elif [ "$1" = "run" ]; then
...
elif [ "$1" = "start" ] ; then
...
elif [ "$1" = "stop" ] ; then
...
elif [ "$1" = "configtest" ] ; then
...
elif [ "$1" = "version" ] ; then
...
else
echo "Usage: catalina.sh ( commands ... )"
echo "commands:"
if $os400; then
echo " debug Start Catalina in a debugger (not available on OS400)"
echo " debug -security Debug Catalina with a security manager (not available on OS400)"
else
echo " debug Start Catalina in a debugger"
echo " debug -security Debug Catalina with a security manager"
fi
echo " jpda start Start Catalina under JPDA debugger"
echo " run Start Catalina in the current window"
echo " run -security Start in the current window with security manager"
echo " start Start Catalina in a separate window"
echo " start -security Start in a separate window with security manager"
echo " stop Stop Catalina, waiting up to 5 seconds for the process to end"
echo " stop n Stop Catalina, waiting up to n seconds for the process to end"
echo " stop -force Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running"
echo " stop n -force Stop Catalina, wait up to n seconds and then use kill -KILL if still running"
echo " version What version of tomcat are you running?"
echo "Note: Waiting for the process to end and use of the -force option require that \$CATALINA_PID is defined"
exit 1
fi
可见,传递给catalina.sh脚本的第一个参数有jpda run start stop configtest version共6个,若第一个参数不是其中之一,就会给出最后的提示。很显然,shutdown.sh脚本肯定也是调用了catalina.sh并传给它stop作为第一个参数。限于篇幅,这里只分析第一个参数是start的情况。
...
elif [ "$1" = "start" ] ; then
if [ ! -z "$CATALINA_PID" ]; then
if [ -f "$CATALINA_PID" ]; then
if [ -s "$CATALINA_PID" ]; then
echo "Existing PID file found during start."
if [ -r "$CATALINA_PID" ]; then
PID=`cat "$CATALINA_PID"`
ps -p $PID >/dev/null 2>&1
if [ $? -eq 0 ] ; then
echo "Tomcat appears to still be running with PID $PID. Start aborted."
exit 1
else
echo "Removing/clearing stale PID file."
rm -f "$CATALINA_PID" >/dev/null 2>&1
if [ $? != 0 ]; then
if [ -w "$CATALINA_PID" ]; then
cat /dev/null > "$CATALINA_PID"
else
echo "Unable to remove or clear stale PID file. Start aborted."
exit 1
fi
fi
fi
else
echo "Unable to read PID file. Start aborted."
exit 1
fi
else
rm -f "$CATALINA_PID" >/dev/null 2>&1
if [ $? != 0 ]; then
if [ ! -w "$CATALINA_PID" ]; then
echo "Unable to remove or write to empty PID file. Start aborted."
exit 1
fi
fi
fi
fi
fi
shift
touch "$CATALINA_OUT"
if [ "$1" = "-security" ] ; then
if [ $have_tty -eq 1 ]; then
echo "Using Security Manager"
fi
shift
eval \"$_RUNJAVA\" \"$LOGGING_CONFIG\" $JAVA_OPTS $CATALINA_OPTS \
-Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
-Djava.security.manager \
-Djava.security.policy==\"$CATALINA_BASE/conf/catalina.policy\" \
-Dcatalina.base=\"$CATALINA_BASE\" \
-Dcatalina.home=\"$CATALINA_HOME\" \
-Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
else
eval \"$_RUNJAVA\" \"$LOGGING_CONFIG\" $JAVA_OPTS $CATALINA_OPTS \
-Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
-Dcatalina.base=\"$CATALINA_BASE\" \
-Dcatalina.home=\"$CATALINA_HOME\" \
-Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
fi
if [ ! -z "$CATALINA_PID" ]; then
echo $! > "$CATALINA_PID"
fi
elif [ "$1" = "stop" ] ; then
...
首先是一堆if语句,用于判断CATALINA_PID变量,这些代码暂时可以忽略,因为:我没有在脚本中发现对这个变量进行赋值的语句;也没有触发过与之有关的错误。所以往下看,shift命令干掉了刚刚的start参数,使得原来的第二个参数变成了第一个;然后touch了一下log文件。
由于很少使用-security选项,所以直接跳到下一部分:
eval \"$_RUNJAVA\" \"$LOGGING_CONFIG\" $JAVA_OPTS $CATALINA_OPTS \
-Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
-Dcatalina.base=\"$CATALINA_BASE\" \
-Dcatalina.home=\"$CATALINA_HOME\" \
-Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
eval后面的一堆变量是在setclasspath.sh脚本中定义的,然后是一堆java选项,紧接着就是主函数登场了org.apache.catalina.startup.Bootstrap,并传入参数"$@"和start,最后一句是一个重定向以及在背景中执行。