Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #7469: /etc/init.d/rudder-jetty restart does not restart jetty #830

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion rudder-jetty/SOURCES/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ localdepends: ./jetty7
patch -p0 -s < jetty-init-stop-fix.patch
patch -p0 -s < jetty-init-sizecheck.patch
patch -p0 -s < jetty-init-use-rudder-jetty-defaults.patch
patch -p0 -s < jetty-init-prevent-false-failed-starts.patch
patch -p0 -s < patches/jetty/jetty-init-prevent-false-failed-starts.patch
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this file to ease merges into the upper branches.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

patch -p0 -s < jetty-init-redirect-stderrout.patch
patch -p0 -s < patches/jetty/jetty-init-stop-forcestop.patch

cp ./jetty7/bin/jetty.sh ./jetty7/bin/jetty-debian.sh
cp ./jetty7/bin/jetty.sh ./jetty7/bin/jetty-sles.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
fi

- if [ $UID -eq 0 ] && type start-stop-daemon > /dev/null 2>&1
+ if [ $(ps aux|grep -cE "[j]ava .* /opt/rudder/jetty7/start.jar") -ne 0 ]
+ if [ $(${PS_COMMAND} | grep -cE "[j]ava .* /opt/rudder/jetty7/start.jar") -ne 0 ]
+ then
+ echo "already running."
+ exit 0
Expand Down
57 changes: 57 additions & 0 deletions rudder-jetty/SOURCES/patches/jetty/jetty-init-stop-forcestop.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
--- jetty7/bin/jetty.sh.orig 2015-12-07 19:25:57.456283949 +0100
+++ jetty7/bin/jetty.sh 2015-12-07 19:41:05.075633380 +0100
@@ -164,6 +164,21 @@
ACTION=$1
shift

+# Detect the correct ps tool to use
+ns=$(ps --no-header -o utsns --pid $$ 2>/dev/null || true)
+if [ -e "/proc/bc/0" ]; then # we have openvz
+ if [ -e /bin/vzps ]; then # we have vzps
+ PS_COMMAND="/bin/vzps -E 0"
+ else # use rudder provided vzps
+ PS_COMMAND="/opt/rudder/bin/vzps.py -E 0"
+ fi
+elif [ -n "${ns}" ]; then # we have namespaces
+ # the sed is here to prepend a fake user field that is removed by the -o option (it is never used)
+ PS_COMMAND="eval ps --no-header -e -O utsns | grep -E '^[[:space:]]*[[:digit:]]*[[:space:]]+${ns}' | sed 's/^/user /'"
+else # standard unix
+ PS_COMMAND="ps -ef"
+fi
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied from rudder-agent.init

+
##################################################
# Read any configuration files
##################################################
@@ -553,7 +568,7 @@
start-stop-daemon -K -p"$JETTY_PID" -d"$JETTY_HOME" -a "$JAVA" -s KILL
fi
if (( TIMEOUT < -10 )); then
- echo "Failed to stop Jetty. Giving up."
+ echo "Failed to stop Jetty. Trying with force..."
break
fi

@@ -574,7 +589,7 @@
kill -KILL "$PID" 2>/dev/null
fi
if (( TIMEOUT < -10 )); then
- echo "Failed to stop Jetty. Giving up."
+ echo "Failed to stop Jetty. Trying with force..."
break
fi

@@ -587,6 +602,14 @@
echo OK
fi

+ # Ensure jetty is not still running
+ PIDS=`${PS_COMMAND} | egrep "[j]ava .* /opt/rudder/jetty7/start.jar" | awk '{print $2}'`
+ for PID in ${PIDS}
+ do
+ # Still running. We need to kill it with the force.
+ kill -KILL ${PID}
+ done
+
;;

restart)