diff --git a/jetty-distribution/src/main/resources/bin/jetty.sh b/jetty-distribution/src/main/resources/bin/jetty.sh index 99652a12b51..b28c33a83b9 100755 --- a/jetty-distribution/src/main/resources/bin/jetty.sh +++ b/jetty-distribution/src/main/resources/bin/jetty.sh @@ -106,7 +106,7 @@ findDirectory() running() { - local PID=$(head -n 1 "$1" 2>/dev/null) || return 1 + local PID=$(cat "$1" 2>/dev/null) || return 1 kill -0 "$PID" 2>/dev/null } @@ -119,7 +119,7 @@ started() [ -z "$(grep STARTED $1)" ] || return 0 [ -z "$(grep STOPPED $1)" ] || return 1 [ -z "$(grep FAILED $1)" ] || return 1 - local PID=$(head -n 1 "$1" 2>/dev/null) || return 1 + local PID=$(cat "$2" 2>/dev/null) || return 1 kill -0 "$PID" 2>/dev/null || return 1 echo -n ". " done @@ -342,7 +342,9 @@ if [ -z "$JETTY_PID" ] then JETTY_PID="$JETTY_RUN/jetty.pid" fi -JAVA_OPTIONS+=("-Djetty.pid=$JETTY_PID") +JETTY_STATE=$(dirname $JETTY_PID)/jetty.state +JAVA_OPTIONS+=("-Djetty.state=$JETTY_STATE") +rm -f $JETTY_STATE ################################################## # Setup JAVA if unset @@ -473,12 +475,16 @@ case "$ACTION" in fi - if started "$JETTY_PID" + if expr "${CONFIGS[*]}" : '.*etc/jetty-started.xml.*' >/dev/null then - echo "OK `date`" + if started "$JETTY_STATE" "$JETTY_PID" + then + echo "OK `date`" + else + echo "FAILED `date`" + fi else - echo "FAILED `date`" - exit 1 + echo "ok `date`" fi ;; @@ -500,7 +506,7 @@ case "$ACTION" in rm -f "$JETTY_PID" echo OK else - PID=$(head -n 1 "$JETTY_PID" 2>/dev/null) + PID=$(cat "$JETTY_PID" 2>/dev/null) kill "$PID" 2>/dev/null TIMEOUT=30