Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 | # contributor license agreements. See the NOTICE file distributed with |
| 5 | # this work for additional information regarding copyright ownership. |
| 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 |
| 7 | # (the "License"); you may not use this file except in compliance with |
| 8 | # the License. You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | |
| 18 | # ----------------------------------------------------------------------------- |
| 19 | # Start/Stop Script for the CATALINA Server |
| 20 | # |
| 21 | # Environment Variable Prerequisites |
| 22 | # |
| 23 | # CATALINA_HOME May point at your Catalina "build" directory. |
| 24 | # |
| 25 | # CATALINA_BASE (Optional) Base directory for resolving dynamic portions |
| 26 | # of a Catalina installation. If not present, resolves to |
| 27 | # the same directory that CATALINA_HOME points to. |
| 28 | # |
| 29 | # CATALINA_OUT (Optional) Full path to a file where stdout and stderr |
| 30 | # will be redirected. |
| 31 | # Default is $CATALINA_BASE/logs/catalina.out |
| 32 | # |
| 33 | # CATALINA_OPTS (Optional) Java runtime options used when the "start", |
| 34 | # or "run" command is executed. |
| 35 | # |
| 36 | # CATALINA_TMPDIR (Optional) Directory path location of temporary directory |
| 37 | # the JVM should use (java.io.tmpdir). Defaults to |
| 38 | # $CATALINA_BASE/temp. |
| 39 | # |
| 40 | # JAVA_HOME Must point at your Java Development Kit installation. |
| 41 | # Required to run the with the "debug" argument. |
| 42 | # |
| 43 | # JRE_HOME Must point at your Java Development Kit installation. |
| 44 | # Defaults to JAVA_HOME if empty. |
| 45 | # |
| 46 | # JAVA_OPTS (Optional) Java runtime options used when the "start", |
| 47 | # "stop", or "run" command is executed. |
| 48 | # |
| 49 | # JAVA_ENDORSED_DIRS (Optional) Lists of of colon separated directories |
| 50 | # containing some jars in order to allow replacement of APIs |
| 51 | # created outside of the JCP (i.e. DOM and SAX from W3C). |
| 52 | # It can also be used to update the XML parser implementation. |
| 53 | # Defaults to $CATALINA_HOME/endorsed. |
| 54 | # |
| 55 | # JPDA_TRANSPORT (Optional) JPDA transport used when the "jpda start" |
| 56 | # command is executed. The default is "dt_socket". |
| 57 | # |
| 58 | # JPDA_ADDRESS (Optional) Java runtime options used when the "jpda start" |
| 59 | # command is executed. The default is 8000. |
| 60 | # |
| 61 | # JPDA_SUSPEND (Optional) Java runtime options used when the "jpda start" |
| 62 | # command is executed. Specifies whether JVM should suspend |
| 63 | # execution immediately after startup. Default is "n". |
| 64 | # |
| 65 | # JPDA_OPTS (Optional) Java runtime options used when the "jpda start" |
| 66 | # command is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS, |
| 67 | # and JPDA_SUSPEND are ignored. Thus, all required jpda |
| 68 | # options MUST be specified. The default is: |
| 69 | # |
| 70 | # -agentlib:jdwp=transport=$JPDA_TRANSPORT, |
| 71 | # address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND |
| 72 | # |
| 73 | # CATALINA_PID (Optional) Path of the file which should contains the pid |
| 74 | # of catalina startup java process, when start (fork) is used |
| 75 | # |
| 76 | # LOGGING_CONFIG (Optional) Override Tomcat's logging config file |
| 77 | # Example (all one line) |
| 78 | # LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties" |
| 79 | # |
| 80 | # LOGGING_MANAGER (Optional) Override Tomcat's logging manager |
| 81 | # Example (all one line) |
| 82 | # LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" |
| 83 | # ----------------------------------------------------------------------------- |
| 84 | |
| 85 | # OS specific support. $var _must_ be set to either true or false. |
| 86 | cygwin=false |
| 87 | os400=false |
| 88 | darwin=false |
| 89 | case "`uname`" in |
| 90 | CYGWIN*) cygwin=true;; |
| 91 | OS400*) os400=true;; |
| 92 | Darwin*) darwin=true;; |
| 93 | esac |
| 94 | |
| 95 | # resolve links - $0 may be a softlink |
| 96 | PRG="$0" |
| 97 | |
| 98 | while [ -h "$PRG" ]; do |
| 99 | ls=`ls -ld "$PRG"` |
| 100 | link=`expr "$ls" : '.*-> \(.*\)$'` |
| 101 | if expr "$link" : '/.*' > /dev/null; then |
| 102 | PRG="$link" |
| 103 | else |
| 104 | PRG=`dirname "$PRG"`/"$link" |
| 105 | fi |
| 106 | done |
| 107 | |
| 108 | # Get standard environment variables |
| 109 | PRGDIR=`dirname "$PRG"` |
| 110 | |
| 111 | # Only set CATALINA_HOME if not already set |
| 112 | [ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd` |
| 113 | |
| 114 | # Copy CATALINA_BASE from CATALINA_HOME if not already set |
| 115 | [ -z "$CATALINA_BASE" ] && CATALINA_BASE="$CATALINA_HOME" |
| 116 | |
| 117 | # Ensure that any user defined CLASSPATH variables are not used on startup, |
| 118 | # but allow them to be specified in setenv.sh, in rare case when it is needed. |
| 119 | CLASSPATH= |
| 120 | |
| 121 | if [ -r "$CATALINA_BASE/bin/setenv.sh" ]; then |
| 122 | . "$CATALINA_BASE/bin/setenv.sh" |
| 123 | elif [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then |
| 124 | . "$CATALINA_HOME/bin/setenv.sh" |
| 125 | fi |
| 126 | |
| 127 | # For Cygwin, ensure paths are in UNIX format before anything is touched |
| 128 | if $cygwin; then |
| 129 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` |
| 130 | [ -n "$JRE_HOME" ] && JRE_HOME=`cygpath --unix "$JRE_HOME"` |
| 131 | [ -n "$CATALINA_HOME" ] && CATALINA_HOME=`cygpath --unix "$CATALINA_HOME"` |
| 132 | [ -n "$CATALINA_BASE" ] && CATALINA_BASE=`cygpath --unix "$CATALINA_BASE"` |
| 133 | [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"` |
| 134 | fi |
| 135 | |
| 136 | # For OS400 |
| 137 | if $os400; then |
| 138 | # Set job priority to standard for interactive (interactive - 6) by using |
| 139 | # the interactive priority - 6, the helper threads that respond to requests |
| 140 | # will be running at the same priority as interactive jobs. |
| 141 | COMMAND='chgjob job('$JOBNAME') runpty(6)' |
| 142 | system $COMMAND |
| 143 | |
| 144 | # Enable multi threading |
| 145 | export QIBM_MULTI_THREADED=Y |
| 146 | fi |
| 147 | |
| 148 | # Get standard Java environment variables |
| 149 | if $os400; then |
| 150 | # -r will Only work on the os400 if the files are: |
| 151 | # 1. owned by the user |
| 152 | # 2. owned by the PRIMARY group of the user |
| 153 | # this will not work if the user belongs in secondary groups |
| 154 | BASEDIR="$CATALINA_HOME" |
| 155 | . "$CATALINA_HOME"/bin/setclasspath.sh |
| 156 | else |
| 157 | if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then |
| 158 | BASEDIR="$CATALINA_HOME" |
| 159 | . "$CATALINA_HOME"/bin/setclasspath.sh |
| 160 | else |
| 161 | echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh" |
| 162 | echo "This file is needed to run this program" |
| 163 | exit 1 |
| 164 | fi |
| 165 | fi |
| 166 | |
| 167 | if [ -z "$CATALINA_BASE" ] ; then |
| 168 | CATALINA_BASE="$CATALINA_HOME" |
| 169 | fi |
| 170 | |
| 171 | # Add tomcat-juli.jar and bootstrap.jar to classpath |
| 172 | # tomcat-juli.jar can be over-ridden per instance |
| 173 | if [ ! -z "$CLASSPATH" ] ; then |
| 174 | CLASSPATH="$CLASSPATH": |
| 175 | fi |
| 176 | if [ "$CATALINA_BASE" != "$CATALINA_HOME" ] && [ -r "$CATALINA_BASE/bin/tomcat-juli.jar" ] ; then |
| 177 | CLASSPATH="$CLASSPATH""$CATALINA_BASE"/bin/tomcat-juli.jar:"$CATALINA_HOME"/bin/bootstrap.jar |
| 178 | else |
| 179 | CLASSPATH="$CLASSPATH""$CATALINA_HOME"/bin/bootstrap.jar |
| 180 | fi |
| 181 | |
| 182 | if [ -z "$CATALINA_OUT" ] ; then |
| 183 | CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out |
| 184 | fi |
| 185 | |
| 186 | if [ -z "$CATALINA_TMPDIR" ] ; then |
| 187 | # Define the java.io.tmpdir to use for Catalina |
| 188 | CATALINA_TMPDIR="$CATALINA_BASE"/temp |
| 189 | fi |
| 190 | |
| 191 | # Bugzilla 37848: When no TTY is available, don't output to console |
| 192 | have_tty=0 |
| 193 | if [ "`tty`" != "not a tty" ]; then |
| 194 | have_tty=1 |
| 195 | fi |
| 196 | |
| 197 | # For Cygwin, switch paths to Windows format before running java |
| 198 | if $cygwin; then |
| 199 | JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"` |
| 200 | JRE_HOME=`cygpath --absolute --windows "$JRE_HOME"` |
| 201 | CATALINA_HOME=`cygpath --absolute --windows "$CATALINA_HOME"` |
| 202 | CATALINA_BASE=`cygpath --absolute --windows "$CATALINA_BASE"` |
| 203 | CATALINA_TMPDIR=`cygpath --absolute --windows "$CATALINA_TMPDIR"` |
| 204 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` |
| 205 | JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"` |
| 206 | fi |
| 207 | |
| 208 | # Set juli LogManager config file if it is present and an override has not been issued |
| 209 | if [ -z "$LOGGING_CONFIG" ]; then |
| 210 | if [ -r "$CATALINA_BASE"/conf/logging.properties ]; then |
| 211 | LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties" |
| 212 | else |
| 213 | # Bugzilla 45585 |
| 214 | LOGGING_CONFIG="-Dnop" |
| 215 | fi |
| 216 | fi |
| 217 | |
| 218 | if [ -z "$LOGGING_MANAGER" ]; then |
| 219 | LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" |
| 220 | fi |
| 221 | |
| 222 | # ----- Execute The Requested Command ----------------------------------------- |
| 223 | |
| 224 | # Bugzilla 37848: only output this if we have a TTY |
| 225 | if [ $have_tty -eq 1 ]; then |
| 226 | echo "Using CATALINA_BASE: $CATALINA_BASE" |
| 227 | echo "Using CATALINA_HOME: $CATALINA_HOME" |
| 228 | echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR" |
| 229 | if [ "$1" = "debug" ] ; then |
| 230 | echo "Using JAVA_HOME: $JAVA_HOME" |
| 231 | else |
| 232 | echo "Using JRE_HOME: $JRE_HOME" |
| 233 | fi |
| 234 | echo "Using CLASSPATH: $CLASSPATH" |
| 235 | if [ ! -z "$CATALINA_PID" ]; then |
| 236 | echo "Using CATALINA_PID: $CATALINA_PID" |
| 237 | fi |
| 238 | fi |
| 239 | |
| 240 | if [ "$1" = "jpda" ] ; then |
| 241 | if [ -z "$JPDA_TRANSPORT" ]; then |
| 242 | JPDA_TRANSPORT="dt_socket" |
| 243 | fi |
| 244 | if [ -z "$JPDA_ADDRESS" ]; then |
| 245 | JPDA_ADDRESS="8000" |
| 246 | fi |
| 247 | if [ -z "$JPDA_SUSPEND" ]; then |
| 248 | JPDA_SUSPEND="n" |
| 249 | fi |
| 250 | if [ -z "$JPDA_OPTS" ]; then |
| 251 | JPDA_OPTS="-agentlib:jdwp=transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND" |
| 252 | fi |
| 253 | CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS" |
| 254 | shift |
| 255 | fi |
| 256 | |
| 257 | if [ "$1" = "debug" ] ; then |
| 258 | if $os400; then |
| 259 | echo "Debug command not available on OS400" |
| 260 | exit 1 |
| 261 | else |
| 262 | shift |
| 263 | if [ "$1" = "-security" ] ; then |
| 264 | if [ $have_tty -eq 1 ]; then |
| 265 | echo "Using Security Manager" |
| 266 | fi |
| 267 | shift |
| 268 | exec "$_RUNJDB" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \ |
| 269 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
| 270 | -sourcepath "$CATALINA_HOME"/../../java \ |
| 271 | -Djava.security.manager \ |
| 272 | -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \ |
| 273 | -Dcatalina.base="$CATALINA_BASE" \ |
| 274 | -Dcatalina.home="$CATALINA_HOME" \ |
| 275 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
| 276 | org.apache.catalina.startup.Bootstrap "$@" start |
| 277 | else |
| 278 | exec "$_RUNJDB" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \ |
| 279 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
| 280 | -sourcepath "$CATALINA_HOME"/../../java \ |
| 281 | -Dcatalina.base="$CATALINA_BASE" \ |
| 282 | -Dcatalina.home="$CATALINA_HOME" \ |
| 283 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
| 284 | org.apache.catalina.startup.Bootstrap "$@" start |
| 285 | fi |
| 286 | fi |
| 287 | |
| 288 | elif [ "$1" = "run" ]; then |
| 289 | |
| 290 | shift |
| 291 | if [ "$1" = "-security" ] ; then |
| 292 | if [ $have_tty -eq 1 ]; then |
| 293 | echo "Using Security Manager" |
| 294 | fi |
| 295 | shift |
| 296 | exec "$_RUNJAVA" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \ |
| 297 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
| 298 | -Djava.security.manager \ |
| 299 | -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \ |
| 300 | -Dcatalina.base="$CATALINA_BASE" \ |
| 301 | -Dcatalina.home="$CATALINA_HOME" \ |
| 302 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
| 303 | org.apache.catalina.startup.Bootstrap "$@" start |
| 304 | else |
| 305 | exec "$_RUNJAVA" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \ |
| 306 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
| 307 | -Dcatalina.base="$CATALINA_BASE" \ |
| 308 | -Dcatalina.home="$CATALINA_HOME" \ |
| 309 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
| 310 | org.apache.catalina.startup.Bootstrap "$@" start |
| 311 | fi |
| 312 | |
| 313 | elif [ "$1" = "start" ] ; then |
| 314 | |
| 315 | if [ ! -z "$CATALINA_PID" ]; then |
| 316 | if [ -f "$CATALINA_PID" ]; then |
| 317 | if [ -s "$CATALINA_PID" ]; then |
| 318 | echo "Existing PID file found during start." |
| 319 | if [ -r "$CATALINA_PID" ]; then |
| 320 | PID=`cat "$CATALINA_PID"` |
| 321 | ps -p $PID >/dev/null 2>&1 |
| 322 | if [ $? -eq 0 ] ; then |
| 323 | echo "Tomcat appears to still be running with PID $PID. Start aborted." |
| 324 | exit 1 |
| 325 | else |
| 326 | echo "Removing/clearing stale PID file." |
| 327 | rm -f "$CATALINA_PID" >/dev/null 2>&1 |
| 328 | if [ $? != 0 ]; then |
| 329 | if [ -w "$CATALINA_PID" ]; then |
| 330 | cat /dev/null > "$CATALINA_PID" |
| 331 | else |
| 332 | echo "Unable to remove or clear stale PID file. Start aborted." |
| 333 | exit 1 |
| 334 | fi |
| 335 | fi |
| 336 | fi |
| 337 | else |
| 338 | echo "Unable to read PID file. Start aborted." |
| 339 | exit 1 |
| 340 | fi |
| 341 | else |
| 342 | rm -f "$CATALINA_PID" >/dev/null 2>&1 |
| 343 | if [ $? != 0 ]; then |
| 344 | if [ ! -w "$CATALINA_PID" ]; then |
| 345 | echo "Unable to remove or write to empty PID file. Start aborted." |
| 346 | exit 1 |
| 347 | fi |
| 348 | fi |
| 349 | fi |
| 350 | fi |
| 351 | fi |
| 352 | |
| 353 | shift |
| 354 | touch "$CATALINA_OUT" |
| 355 | if [ "$1" = "-security" ] ; then |
| 356 | if [ $have_tty -eq 1 ]; then |
| 357 | echo "Using Security Manager" |
| 358 | fi |
| 359 | shift |
| 360 | "$_RUNJAVA" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \ |
| 361 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
| 362 | -Djava.security.manager \ |
| 363 | -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \ |
| 364 | -Dcatalina.base="$CATALINA_BASE" \ |
| 365 | -Dcatalina.home="$CATALINA_HOME" \ |
| 366 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
| 367 | org.apache.catalina.startup.Bootstrap "$@" start \ |
| 368 | >> "$CATALINA_OUT" 2>&1 & |
| 369 | |
| 370 | else |
| 371 | "$_RUNJAVA" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \ |
| 372 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
| 373 | -Dcatalina.base="$CATALINA_BASE" \ |
| 374 | -Dcatalina.home="$CATALINA_HOME" \ |
| 375 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
| 376 | org.apache.catalina.startup.Bootstrap "$@" start \ |
| 377 | >> "$CATALINA_OUT" 2>&1 & |
| 378 | |
| 379 | fi |
| 380 | |
| 381 | if [ ! -z "$CATALINA_PID" ]; then |
| 382 | echo $! > "$CATALINA_PID" |
| 383 | fi |
| 384 | |
| 385 | elif [ "$1" = "stop" ] ; then |
| 386 | |
| 387 | shift |
| 388 | |
| 389 | SLEEP=5 |
| 390 | if [ ! -z "$1" ]; then |
| 391 | echo $1 | grep "[^0-9]" >/dev/null 2>&1 |
| 392 | if [ $? -gt 0 ]; then |
| 393 | SLEEP=$1 |
| 394 | shift |
| 395 | fi |
| 396 | fi |
| 397 | |
| 398 | FORCE=0 |
| 399 | if [ "$1" = "-force" ]; then |
| 400 | shift |
| 401 | FORCE=1 |
| 402 | fi |
| 403 | |
| 404 | if [ ! -z "$CATALINA_PID" ]; then |
| 405 | if [ -f "$CATALINA_PID" ]; then |
| 406 | if [ -s "$CATALINA_PID" ]; then |
| 407 | kill -0 `cat "$CATALINA_PID"` >/dev/null 2>&1 |
| 408 | if [ $? -gt 0 ]; then |
| 409 | echo "PID file found but no matching process was found. Stop aborted." |
| 410 | exit 1 |
| 411 | fi |
| 412 | else |
| 413 | echo "PID file is empty and has been ignored." |
| 414 | fi |
| 415 | else |
| 416 | echo "\$CATALINA_PID was set but the specified file does not exist. Is Tomcat running? Stop aborted." |
| 417 | exit 1 |
| 418 | fi |
| 419 | fi |
| 420 | |
| 421 | "$_RUNJAVA" $LOGGING_MANAGER $JAVA_OPTS \ |
| 422 | -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ |
| 423 | -Dcatalina.base="$CATALINA_BASE" \ |
| 424 | -Dcatalina.home="$CATALINA_HOME" \ |
| 425 | -Djava.io.tmpdir="$CATALINA_TMPDIR" \ |
| 426 | org.apache.catalina.startup.Bootstrap "$@" stop |
| 427 | |
| 428 | if [ ! -z "$CATALINA_PID" ]; then |
| 429 | if [ -f "$CATALINA_PID" ]; then |
| 430 | while [ $SLEEP -ge 0 ]; do |
| 431 | kill -0 `cat "$CATALINA_PID"` >/dev/null 2>&1 |
| 432 | if [ $? -gt 0 ]; then |
| 433 | rm -f "$CATALINA_PID" >/dev/null 2>&1 |
| 434 | if [ $? != 0 ]; then |
| 435 | if [ -w "$CATALINA_PID" ]; then |
| 436 | cat /dev/null > "$CATALINA_PID" |
| 437 | else |
| 438 | echo "Tomcat stopped but the PID file could not be removed or cleared." |
| 439 | fi |
| 440 | fi |
| 441 | break |
| 442 | fi |
| 443 | if [ $SLEEP -gt 0 ]; then |
| 444 | sleep 1 |
| 445 | fi |
| 446 | if [ $SLEEP -eq 0 ]; then |
| 447 | if [ $FORCE -eq 0 ]; then |
| 448 | echo "Tomcat did not stop in time. PID file was not removed." |
| 449 | fi |
| 450 | fi |
| 451 | SLEEP=`expr $SLEEP - 1 ` |
| 452 | done |
| 453 | fi |
| 454 | fi |
| 455 | |
| 456 | if [ $FORCE -eq 1 ]; then |
| 457 | if [ -z "$CATALINA_PID" ]; then |
| 458 | echo "Kill failed: \$CATALINA_PID not set" |
| 459 | else |
| 460 | if [ -f "$CATALINA_PID" ]; then |
| 461 | PID=`cat "$CATALINA_PID"` |
| 462 | echo "Killing Tomcat with the PID: $PID" |
| 463 | kill -9 $PID |
| 464 | rm -f "$CATALINA_PID" >/dev/null 2>&1 |
| 465 | if [ $? != 0 ]; then |
| 466 | echo "Tomcat was killed but the PID file could not be removed." |
| 467 | fi |
| 468 | fi |
| 469 | fi |
| 470 | fi |
| 471 | |
| 472 | elif [ "$1" = "version" ] ; then |
| 473 | |
| 474 | "$_RUNJAVA" \ |
| 475 | -classpath "$CATALINA_HOME/lib/catalina.jar" \ |
| 476 | org.apache.catalina.util.ServerInfo |
| 477 | |
| 478 | else |
| 479 | |
| 480 | echo "Usage: catalina.sh ( commands ... )" |
| 481 | echo "commands:" |
| 482 | if $os400; then |
| 483 | echo " debug Start Catalina in a debugger (not available on OS400)" |
| 484 | echo " debug -security Debug Catalina with a security manager (not available on OS400)" |
| 485 | else |
| 486 | echo " debug Start Catalina in a debugger" |
| 487 | echo " debug -security Debug Catalina with a security manager" |
| 488 | fi |
| 489 | echo " jpda start Start Catalina under JPDA debugger" |
| 490 | echo " run Start Catalina in the current window" |
| 491 | echo " run -security Start in the current window with security manager" |
| 492 | echo " start Start Catalina in a separate window" |
| 493 | echo " start -security Start in a separate window with security manager" |
| 494 | echo " stop Stop Catalina, waiting up to 5 seconds for the process to end" |
| 495 | echo " stop n Stop Catalina, waiting up to n seconds for the process to end" |
| 496 | echo " stop -force Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running" |
| 497 | echo " stop n -force Stop Catalina, wait up to n seconds and then use kill -KILL if still running" |
| 498 | echo " version What version of tomcat are you running?" |
| 499 | echo "Note: Waiting for the process to end and use of the -force option require that \$CATALINA_PID is defined" |
| 500 | exit 1 |
| 501 | |
| 502 | fi |