catalina.sh详解

1 - 概述
脚本catalina.sh用于启动和关闭tomcat服务器,是最关键的脚本
另外的脚本startup.sh和shutdown.sh都是使用不同的参数调用了该脚本
该脚本的使用方法如下(引自该脚本本身):

echo “Usage: catalina.sh ( commands … )”
echo “commands:”
echo " debug Start Catalina in a debugger"
echo " debug -security Debug Catalina with a security manager"
echo " embedded Start Catalina in embedded mode"
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"
2 - 脚本分析
#!/bin/sh

=============================================================

该脚本设置正确的环境变量和系统信息,然后启动或者停止tomcat server

具体的操作是:

使用命令行参数作为args的实参,调用org.apache.catalina.startup.Bootstrap.main(String[])

==============================================================

-----------------------------------------------------------------------------

Start/Stop Script for the CATALINA Server

Environment Variable Prequisites

CATALINA_HOME May point at your Catalina “build” directory.

CATALINA_BASE (Optional) Base directory for resolving dynamic portions

of a Catalina installation. If not present, resolves to

the same directory that CATALINA_HOME points to.

CATALINA_OPTS (Optional) Java runtime options used when the “start”,

“stop”, or “run” command is executed.

CATALINA_TMPDIR (Optional) Directory path location of temporary directory

the JVM should use (java.io.tmpdir). Defaults to

$CATALINA_BASE/temp.

JAVA_HOME Must point at your Java Development Kit installation.

JAVA_OPTS (Optional) Java runtime options used when the “start”,

“stop”, or “run” command is executed.

JPDA_TRANSPORT (Optional) JPDA transport used when the “jpda start”

command is executed. The default is “dt_socket”.

JPDA_ADDRESS (Optional) Java runtime options used when the “jpda start”

command is executed. The default is 8000.

JSSE_HOME (Optional) May point at your Java Secure Sockets Extension

(JSSE) installation, whose JAR files will be added to the

system class path used to start Tomcat.

CATALINA_PID (Optional) Path of the file which should contains the pid

of catalina startup java process, when start (fork) is used

-----------------------------------------------------------------------------

OS specific support. $var must be set to either true or false.

cygwin=false
case “uname” in
CYGWIN*) cygwin=true;;
esac

PRG是被执行的脚本的名称,可以认为PRG==“catalina.sh”,也可能是某个符号链,指向该脚本。

PRG="$0"

处理了一下PRG,等循环跳出之后PRG成为 ???

while [ -h " P R G " ] ; d o l s = ‘ l s − l d " PRG" ]; do ls=`ls -ld " PRG"];dols=lsld"PRG"link=expr "KaTeX parse error: Can't use function '\(' in math mode at position 13: ls" : '.*-> \̲(̲.*\)'if expr "$link" : '.*/.*' > /dev/null; then PRG="$link" else PRG=dirname “ P R G " ‘ / " PRG"`/" PRG"/"link”
fi
done

PRGDIR是PRG的目录路径名称

PRGDIR=dirname "$PRG"

执行$CATALINA_HOME/BIN/setenv.sh来设置环境变量

[ -r filename ] 是判断是否文件存在且可读

CATALINA_HOME=cd "$PRGDIR/.." ; pwd
if [ -r “ C A T A L I N A H O M E " / b i n / s e t e n v . s h ] ; t h e n . " CATALINA_HOME"/bin/setenv.sh ]; then . " CATALINAHOME"/bin/setenv.sh];then."CATALINA_HOME”/bin/setenv.sh
fi

For Cygwin, 确保所有的路径名都符合UNIX格式

if c y g w i n ; t h e n [ − n " cygwin; then [ -n " cygwin;then[n"JAVA_HOME" ] && JAVA_HOME=cygpath --unix "$JAVA_HOME"
[ -n "KaTeX parse error: Expected 'EOF', got '&' at position 18: …TALINA_HOME" ] &̲& CATALINA_HOME…CATALINA_HOME"[ -n "$CATALINA_BASE" ] && CATALINA_BASE=cygpath --unix “ C A T A L I N A B A S E " ‘ [ − n " CATALINA_BASE"` [ -n " CATALINABASE"[n"CLASSPATH” ] && CLASSPATH=cygpath --path --unix "$CLASSPATH"
[ -n “KaTeX parse error: Expected 'EOF', got '&' at position 14: JSSE_HOME" ] &̲& JSSE_HOME=`cy…JSSE_HOME”`
fi

设置用来初始化SystemClassLoader的CLASSPATH变量:通过执行脚本setclasspath.sh完成

注意:脚本setclasspath.sh改变了原来的$CLASSPATH变量,而把它设为:

CLASSPATH= C A T A L I N A H O M E / b i n / b o o t s t r a p . j a r : CATALINA_HOME/bin/bootstrap.jar: CATALI

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值