* Issue #10473 - Better warnings in jetty.sh on filesystem permission issues Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
07f320ab6a
commit
551ad8bba0
|
@ -137,6 +137,13 @@ started()
|
||||||
local STATEFILE=$1
|
local STATEFILE=$1
|
||||||
local PIDFILE=$2
|
local PIDFILE=$2
|
||||||
local STARTTIMEOUT=$3
|
local STARTTIMEOUT=$3
|
||||||
|
|
||||||
|
if (( DEBUG )) ; then
|
||||||
|
echo "Looking for $STATEFILE"
|
||||||
|
echo -n "State Parent Directory: "
|
||||||
|
ls -lad $(dirname $STATEFILE)
|
||||||
|
fi
|
||||||
|
|
||||||
# wait till timeout to see "STARTED" in state file, needs --module=state as argument
|
# wait till timeout to see "STARTED" in state file, needs --module=state as argument
|
||||||
for ((T = 0; T < $STARTTIMEOUT; T++))
|
for ((T = 0; T < $STARTTIMEOUT; T++))
|
||||||
do
|
do
|
||||||
|
@ -162,6 +169,11 @@ started()
|
||||||
done
|
done
|
||||||
(( DEBUG )) && echo "Timeout $STARTTIMEOUT expired waiting for start state from $STATEFILE"
|
(( DEBUG )) && echo "Timeout $STARTTIMEOUT expired waiting for start state from $STATEFILE"
|
||||||
echo " timeout"
|
echo " timeout"
|
||||||
|
if running "$PIDFILE" ; then
|
||||||
|
echo "INFO: Server process is running"
|
||||||
|
else
|
||||||
|
echo "** ERROR: Server process is NOT running"
|
||||||
|
fi
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +185,7 @@ pidKill()
|
||||||
if [ -r $PIDFILE ] ; then
|
if [ -r $PIDFILE ] ; then
|
||||||
local PID=$(tail -1 "$PIDFILE")
|
local PID=$(tail -1 "$PIDFILE")
|
||||||
if [ -z "$PID" ] ; then
|
if [ -z "$PID" ] ; then
|
||||||
echo "ERROR: no pid found in $PIDFILE"
|
echo "** ERROR: no pid found in $PIDFILE"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -204,7 +216,6 @@ pidKill()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
readConfig()
|
readConfig()
|
||||||
{
|
{
|
||||||
(( DEBUG )) && echo "Reading $1.."
|
(( DEBUG )) && echo "Reading $1.."
|
||||||
|
@ -213,26 +224,25 @@ readConfig()
|
||||||
|
|
||||||
dumpEnv()
|
dumpEnv()
|
||||||
{
|
{
|
||||||
echo "JAVA = $JAVA"
|
echo "JAVA = $JAVA"
|
||||||
echo "JAVA_OPTIONS = ${JAVA_OPTIONS[*]}"
|
echo "JAVA_OPTIONS = ${JAVA_OPTIONS[*]}"
|
||||||
echo "JETTY_HOME = $JETTY_HOME"
|
echo "JETTY_HOME = $JETTY_HOME"
|
||||||
echo "JETTY_BASE = $JETTY_BASE"
|
echo "JETTY_BASE = $JETTY_BASE"
|
||||||
echo "START_D = $START_D"
|
echo "START_D = $START_D"
|
||||||
echo "START_INI = $START_INI"
|
echo "START_INI = $START_INI"
|
||||||
echo "JETTY_START = $JETTY_START"
|
echo "JETTY_START = $JETTY_START"
|
||||||
echo "JETTY_CONF = $JETTY_CONF"
|
echo "JETTY_CONF = $JETTY_CONF"
|
||||||
echo "JETTY_ARGS = ${JETTY_ARGS[*]}"
|
echo "JETTY_ARGS = ${JETTY_ARGS[*]}"
|
||||||
echo "JETTY_RUN = $JETTY_RUN"
|
echo "JETTY_RUN = $JETTY_RUN"
|
||||||
echo "JETTY_PID = $JETTY_PID"
|
echo "JETTY_PID = $JETTY_PID"
|
||||||
echo "JETTY_START_LOG = $JETTY_START_LOG"
|
echo "JETTY_START_LOG = $JETTY_START_LOG"
|
||||||
echo "JETTY_STATE = $JETTY_STATE"
|
echo "JETTY_STATE = $JETTY_STATE"
|
||||||
echo "JETTY_START_TIMEOUT = $JETTY_START_TIMEOUT"
|
echo "JETTY_START_TIMEOUT = $JETTY_START_TIMEOUT"
|
||||||
echo "JETTY_SYS_PROPS = $JETTY_SYS_PROPS"
|
echo "JETTY_SYS_PROPS = $JETTY_SYS_PROPS"
|
||||||
echo "RUN_ARGS = ${RUN_ARGS[*]}"
|
echo "RUN_ARGS = ${RUN_ARGS[*]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
# Get the action & configs
|
# Get the action & configs
|
||||||
##################################################
|
##################################################
|
||||||
|
@ -358,7 +368,15 @@ fi
|
||||||
if [ -z "$JETTY_RUN" ]
|
if [ -z "$JETTY_RUN" ]
|
||||||
then
|
then
|
||||||
JETTY_RUN=$(findDirectory -w /var/run /usr/var/run $JETTY_BASE /tmp)/jetty
|
JETTY_RUN=$(findDirectory -w /var/run /usr/var/run $JETTY_BASE /tmp)/jetty
|
||||||
[ -d "$JETTY_RUN" ] || mkdir $JETTY_RUN
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$JETTY_RUN" ] ; then
|
||||||
|
if ! mkdir $JETTY_RUN
|
||||||
|
then
|
||||||
|
echo "** ERROR: Unable to create directory: $JETTY_RUN"
|
||||||
|
echo " Correct issues preventing the creation of \$JETTY_RUN and try again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
|
@ -495,6 +513,11 @@ RUN_ARGS=($JETTY_SYS_PROPS ${JETTY_DRY_RUN[@]})
|
||||||
|
|
||||||
if (( DEBUG ))
|
if (( DEBUG ))
|
||||||
then
|
then
|
||||||
|
if expr "${RUN_ARGS[*]}" : '.*/etc/console-capture.xml.*' > /dev/null
|
||||||
|
then
|
||||||
|
echo "WARNING: Disable console-capture module for best DEBUG results"
|
||||||
|
fi
|
||||||
|
echo "IDs are $(id)"
|
||||||
dumpEnv
|
dumpEnv
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -503,13 +526,27 @@ fi
|
||||||
##################################################
|
##################################################
|
||||||
case "$ACTION" in
|
case "$ACTION" in
|
||||||
start)
|
start)
|
||||||
echo -n "Starting Jetty: "
|
|
||||||
|
|
||||||
if (( NO_START )); then
|
if (( NO_START )); then
|
||||||
echo "Not starting ${NAME} - NO_START=1";
|
echo "Not starting ${NAME} - NO_START=1";
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! touch "$JETTY_PID"
|
||||||
|
then
|
||||||
|
echo "** ERROR: Unable to touch file: $JETTY_PID"
|
||||||
|
echo " Correct issues preventing use of \$JETTY_PID and try again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! touch "$JETTY_STATE"
|
||||||
|
then
|
||||||
|
echo "** ERROR: Unable to touch file: $JETTY_STATE"
|
||||||
|
echo " Correct issues preventing use of \$JETTY_STATE and try again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -n "Starting Jetty: "
|
||||||
|
|
||||||
# Startup from a service file
|
# Startup from a service file
|
||||||
if [ $UID -eq 0 ] && type start-stop-daemon > /dev/null 2>&1
|
if [ $UID -eq 0 ] && type start-stop-daemon > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
|
@ -519,15 +556,16 @@ case "$ACTION" in
|
||||||
CH_USER="--chuid $JETTY_USER"
|
CH_USER="--chuid $JETTY_USER"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ${RUN_ARGS[@]} start-log-file="$JETTY_START_LOG" | xargs start-stop-daemon \
|
echo ${RUN_ARGS[@]} --start-log-file="$JETTY_START_LOG" | xargs start-stop-daemon \
|
||||||
--start $CH_USER \
|
--start $CH_USER \
|
||||||
--pidfile "$JETTY_PID" \
|
--pidfile "$JETTY_PID" \
|
||||||
--chdir "$JETTY_BASE" \
|
--chdir "$JETTY_BASE" \
|
||||||
--background \
|
--background \
|
||||||
|
--output "${JETTY_RUN}/start-stop.log"
|
||||||
--make-pidfile \
|
--make-pidfile \
|
||||||
--startas "$JAVA" \
|
--startas "$JAVA" \
|
||||||
--
|
--
|
||||||
|
(( DEBUG )) && echo "Starting: start-stop-daemon"
|
||||||
else
|
else
|
||||||
|
|
||||||
if running $JETTY_PID
|
if running $JETTY_PID
|
||||||
|
@ -545,16 +583,19 @@ case "$ACTION" in
|
||||||
SU_SHELL="-s $JETTY_SHELL"
|
SU_SHELL="-s $JETTY_SHELL"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
touch "$JETTY_PID"
|
|
||||||
chown "$JETTY_USER" "$JETTY_PID"
|
chown "$JETTY_USER" "$JETTY_PID"
|
||||||
su - "$JETTY_USER" $SU_SHELL -c "
|
su - "$JETTY_USER" $SU_SHELL -c "
|
||||||
cd \"$JETTY_BASE\"
|
cd \"$JETTY_BASE\"
|
||||||
echo ${RUN_ARGS[*]} start-log-file=\"$JETTY_START_LOG\" | xargs ${JAVA} > /dev/null &
|
echo ${RUN_ARGS[*]} --start-log-file=\"$JETTY_START_LOG\" | xargs ${JAVA} > /dev/null &
|
||||||
disown \$!"
|
PID=\$!
|
||||||
|
disown \$PID"
|
||||||
|
(( DEBUG )) && echo "Starting: su shell (w/user $JETTY_USER) on PID $PID"
|
||||||
else
|
else
|
||||||
# Startup if not switching users
|
# Startup if not switching users
|
||||||
echo ${RUN_ARGS[*]} | xargs ${JAVA} > /dev/null &
|
echo ${RUN_ARGS[*]} --start-log-file="${JETTY_START_LOG}" | xargs ${JAVA} > /dev/null &
|
||||||
disown $!
|
PID=$!
|
||||||
|
disown $PID
|
||||||
|
(( DEBUG )) && echo "Starting: java command on PID $PID"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -592,7 +633,7 @@ case "$ACTION" in
|
||||||
else
|
else
|
||||||
# Stop from a non-service path
|
# Stop from a non-service path
|
||||||
if [ ! -r "$JETTY_PID" ] ; then
|
if [ ! -r "$JETTY_PID" ] ; then
|
||||||
echo "ERROR: no pid found at $JETTY_PID"
|
echo "** ERROR: no pid found at $JETTY_PID"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue