升级Tomcat版本 apache-tomcat-7.0.77
diff --git a/tomcat-uid/bin/catalina.sh b/tomcat-uid/bin/catalina.sh
index 45ac16d..33a4803 100644
--- a/tomcat-uid/bin/catalina.sh
+++ b/tomcat-uid/bin/catalina.sh
@@ -16,10 +16,13 @@
# limitations under the License.
# -----------------------------------------------------------------------------
-# Start/Stop Script for the CATALINA Server
+# Control Script for the CATALINA Server
#
# Environment Variable Prerequisites
#
+# Do not set the variables in this script. Instead put them into a script
+# setenv.sh in CATALINA_BASE/bin to keep your customizations separate.
+#
# CATALINA_HOME May point at your Catalina "build" directory.
#
# CATALINA_BASE (Optional) Base directory for resolving dynamic portions
@@ -31,7 +34,11 @@
# Default is $CATALINA_BASE/logs/catalina.out
#
# CATALINA_OPTS (Optional) Java runtime options used when the "start",
-# or "run" command is executed.
+# "run" or "debug" command is executed.
+# Include here and not in JAVA_OPTS all options, that should
+# only be used by Tomcat itself, not by the stop process,
+# the version command etc.
+# Examples are heap size, GC logging, JMX ports etc.
#
# CATALINA_TMPDIR (Optional) Directory path location of temporary directory
# the JVM should use (java.io.tmpdir). Defaults to
@@ -40,11 +47,16 @@
# JAVA_HOME Must point at your Java Development Kit installation.
# Required to run the with the "debug" argument.
#
-# JRE_HOME Must point at your Java Development Kit installation.
-# Defaults to JAVA_HOME if empty.
+# JRE_HOME Must point at your Java Runtime installation.
+# Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME
+# are both set, JRE_HOME is used.
#
-# JAVA_OPTS (Optional) Java runtime options used when the "start",
-# "stop", or "run" command is executed.
+# JAVA_OPTS (Optional) Java runtime options used when any command
+# is executed.
+# Include here and not in CATALINA_OPTS all options, that
+# should be used by Tomcat and also by the stop process,
+# the version command etc.
+# Most options should go into CATALINA_OPTS.
#
# JAVA_ENDORSED_DIRS (Optional) Lists of of colon separated directories
# containing some jars in order to allow replacement of APIs
@@ -70,8 +82,13 @@
# -agentlib:jdwp=transport=$JPDA_TRANSPORT,
# address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND
#
+# JSSE_OPTS (Optional) Java runtime options used to control the TLS
+# implementation when JSSE is used. Default is:
+# "-Djdk.tls.ephemeralDHKeySize=2048"
+#
# CATALINA_PID (Optional) Path of the file which should contains the pid
-# of catalina startup java process, when start (fork) is used
+# of the catalina startup java process, when start (fork) is
+# used
#
# LOGGING_CONFIG (Optional) Override Tomcat's logging config file
# Example (all one line)
@@ -80,16 +97,23 @@
# LOGGING_MANAGER (Optional) Override Tomcat's logging manager
# Example (all one line)
# LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
+#
+# USE_NOHUP (Optional) If set to the string true the start command will
+# use nohup so that the Tomcat process will ignore any hangup
+# signals. Default is "false" unless running on HP-UX in which
+# case the default is "true"
# -----------------------------------------------------------------------------
# OS specific support. $var _must_ be set to either true or false.
cygwin=false
-os400=false
darwin=false
+os400=false
+hpux=false
case "`uname`" in
CYGWIN*) cygwin=true;;
-OS400*) os400=true;;
Darwin*) darwin=true;;
+OS400*) os400=true;;
+HP-UX*) hpux=true;;
esac
# resolve links - $0 may be a softlink
@@ -151,11 +175,9 @@
# 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"
@@ -164,20 +186,11 @@
fi
fi
-if [ -z "$CATALINA_BASE" ] ; then
- CATALINA_BASE="$CATALINA_HOME"
-fi
-
-# Add tomcat-juli.jar and bootstrap.jar to classpath
-# tomcat-juli.jar can be over-ridden per instance
+# Add on extra jar files to CLASSPATH
if [ ! -z "$CLASSPATH" ] ; then
CLASSPATH="$CLASSPATH":
fi
-if [ "$CATALINA_BASE" != "$CATALINA_HOME" ] && [ -r "$CATALINA_BASE/bin/tomcat-juli.jar" ] ; then
- CLASSPATH="$CLASSPATH""$CATALINA_BASE"/bin/tomcat-juli.jar:"$CATALINA_HOME"/bin/bootstrap.jar
-else
- CLASSPATH="$CLASSPATH""$CATALINA_HOME"/bin/bootstrap.jar
-fi
+CLASSPATH="$CLASSPATH""$CATALINA_HOME"/bin/bootstrap.jar
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
@@ -188,6 +201,14 @@
CATALINA_TMPDIR="$CATALINA_BASE"/temp
fi
+# 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
+
# Bugzilla 37848: When no TTY is available, don't output to console
have_tty=0
if [ "`tty`" != "not a tty" ]; then
@@ -205,6 +226,11 @@
JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
fi
+if [ -z "$JSSE_OPTS" ] ; then
+ JSSE_OPTS="-Djdk.tls.ephemeralDHKeySize=2048"
+fi
+JAVA_OPTS="$JAVA_OPTS $JSSE_OPTS"
+
# Set juli LogManager config file if it is present and an override has not been issued
if [ -z "$LOGGING_CONFIG" ]; then
if [ -r "$CATALINA_BASE"/conf/logging.properties ]; then
@@ -219,6 +245,22 @@
LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
fi
+# Uncomment the following line to make the umask available when using the
+# org.apache.catalina.security.SecurityListener
+#JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.security.SecurityListener.UMASK=`umask`"
+
+if [ -z "$USE_NOHUP" ]; then
+ if $hpux; then
+ USE_NOHUP="true"
+ else
+ USE_NOHUP="false"
+ fi
+fi
+unset _NOHUP
+if [ "$USE_NOHUP" = "true" ]; then
+ _NOHUP=nohup
+fi
+
# ----- Execute The Requested Command -----------------------------------------
# Bugzilla 37848: only output this if we have a TTY
@@ -250,7 +292,7 @@
if [ -z "$JPDA_OPTS" ]; then
JPDA_OPTS="-agentlib:jdwp=transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND"
fi
- CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS"
+ CATALINA_OPTS="$JPDA_OPTS $CATALINA_OPTS"
shift
fi
@@ -293,20 +335,20 @@
echo "Using Security Manager"
fi
shift
- exec "$_RUNJAVA" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
- -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
+ eval exec "\"$_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" \
+ -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
else
- exec "$_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" \
+ eval exec "\"$_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
fi
@@ -321,6 +363,8 @@
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."
@@ -357,24 +401,24 @@
echo "Using Security Manager"
fi
shift
- "$_RUNJAVA" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
- -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
+ eval $_NOHUP "\"$_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" \
+ -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 &
+ >> "$CATALINA_OUT" 2>&1 "&"
else
- "$_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" \
+ eval $_NOHUP "\"$_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 &
+ >> "$CATALINA_OUT" 2>&1 "&"
fi
@@ -382,6 +426,8 @@
echo $! > "$CATALINA_PID"
fi
+ echo "Tomcat started."
+
elif [ "$1" = "stop" ] ; then
shift
@@ -417,14 +463,22 @@
exit 1
fi
fi
-
- "$_RUNJAVA" $LOGGING_MANAGER $JAVA_OPTS \
- -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
- -Dcatalina.base="$CATALINA_BASE" \
- -Dcatalina.home="$CATALINA_HOME" \
- -Djava.io.tmpdir="$CATALINA_TMPDIR" \
+
+ eval "\"$_RUNJAVA\"" $LOGGING_MANAGER $JAVA_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 "$@" stop
+ # stop failed. Shutdown port disabled? Try a normal kill.
+ if [ $? != 0 ]; then
+ if [ ! -z "$CATALINA_PID" ]; then
+ echo "The stop command failed. Attempting to signal the process to stop through OS signal."
+ kill -15 `cat "$CATALINA_PID"` >/dev/null 2>&1
+ fi
+ fi
+
if [ ! -z "$CATALINA_PID" ]; then
if [ -f "$CATALINA_PID" ]; then
while [ $SLEEP -ge 0 ]; do
@@ -434,25 +488,32 @@
if [ $? != 0 ]; then
if [ -w "$CATALINA_PID" ]; then
cat /dev/null > "$CATALINA_PID"
+ # If Tomcat has stopped don't try and force a stop with an empty PID file
+ FORCE=0
else
- echo "Tomcat stopped but the PID file could not be removed or cleared."
+ echo "The PID file could not be removed or cleared."
fi
fi
+ echo "Tomcat stopped."
break
fi
if [ $SLEEP -gt 0 ]; then
sleep 1
fi
if [ $SLEEP -eq 0 ]; then
+ echo "Tomcat did not stop in time."
if [ $FORCE -eq 0 ]; then
- echo "Tomcat did not stop in time. PID file was not removed."
+ echo "PID file was not removed."
fi
+ echo "To aid diagnostics a thread dump has been written to standard out."
+ kill -3 `cat "$CATALINA_PID"`
fi
SLEEP=`expr $SLEEP - 1 `
done
fi
fi
+ KILL_SLEEP_INTERVAL=5
if [ $FORCE -eq 1 ]; then
if [ -z "$CATALINA_PID" ]; then
echo "Kill failed: \$CATALINA_PID not set"
@@ -461,14 +522,46 @@
PID=`cat "$CATALINA_PID"`
echo "Killing Tomcat with the PID: $PID"
kill -9 $PID
- rm -f "$CATALINA_PID" >/dev/null 2>&1
- if [ $? != 0 ]; then
- echo "Tomcat was killed but the PID file could not be removed."
+ while [ $KILL_SLEEP_INTERVAL -ge 0 ]; do
+ kill -0 `cat "$CATALINA_PID"` >/dev/null 2>&1
+ if [ $? -gt 0 ]; then
+ rm -f "$CATALINA_PID" >/dev/null 2>&1
+ if [ $? != 0 ]; then
+ if [ -w "$CATALINA_PID" ]; then
+ cat /dev/null > "$CATALINA_PID"
+ else
+ echo "The PID file could not be removed."
+ fi
+ fi
+ echo "The Tomcat process has been killed."
+ break
+ fi
+ if [ $KILL_SLEEP_INTERVAL -gt 0 ]; then
+ sleep 1
+ fi
+ KILL_SLEEP_INTERVAL=`expr $KILL_SLEEP_INTERVAL - 1 `
+ done
+ if [ $KILL_SLEEP_INTERVAL -lt 0 ]; then
+ echo "Tomcat has not been killed completely yet. The process might be waiting on some system call or might be UNINTERRUPTIBLE."
fi
fi
fi
fi
+elif [ "$1" = "configtest" ] ; then
+
+ eval "\"$_RUNJAVA\"" $LOGGING_MANAGER $JAVA_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 configtest
+ result=$?
+ if [ $result -ne 0 ]; then
+ echo "Configuration error detected!"
+ fi
+ exit $result
+
elif [ "$1" = "version" ] ; then
"$_RUNJAVA" \
@@ -495,6 +588,7 @@
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 " configtest Run a basic syntax check on server.xml - check exit code for result"
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