docker下面tomcat执行startup.sh问题
在做docker的时候,碰到了如果使用startup.sh是无法成功启动tomcat,
一定要使用catalina.shrun
后来看到文章:antsshexec无法启动tomcathttp://www.lxway.com/61161411.htm,然后参考catalina.sh的详解:http://www.cnblogs.com/huzhiwei/archive/2012/03/13/2393393.html
发现:运行startup.sh的时候,程序进入到
elif [ "$1" = "start" ] ; then echo "Tomcat started------->start." 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." echo "If the following process is not a Tomcat process, remove the PID file and try again:" ps -f -p $PID 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 echo "Tomcat started------->started->security" shift eval "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $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 echo "Tomcat started------->started->no security" eval "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $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 echo "Tomcat started."
问题出在于:org.apache.catalina.startup.Bootstrap"$@"start\
>>"$CATALINA_OUT"2>&1"&"重定向了日志之后,有多了一个&符号,是这个符号导致启动失败的.去掉就好了.
源码的第384和393行
相关推荐
liujiaoyage 2020-09-09
山有木兮卿有意 2020-06-25
Attend 2020-06-14
citic 2020-06-14
wandererdl 2020-06-14
lfjjia 2020-04-19
ajuan 2020-03-03
wangrui0 2020-02-20
LczPtr 2020-02-14
fcds00 2020-01-28
DonviYang 2020-01-08
Happyunlimited 2020-01-01
学习备忘录 2019-12-08
batoom 2011-03-06
pwl 2008-06-13
IsanaYashiro 2019-11-05
hehuistudent 2008-09-11