mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-15 23:01:04 +00:00
bug 3181: improved stop script, using "shutdown" and wait for process to die; kill if it doesn't
This commit is contained in:
1 parent
ca2d9e8da0
commit
15988ee84f
1 file changed
+16
-5
+16
-5
@@ -15,7 +15,7 @@ if [[ $TELNET_PORT == "" ]] || [[ $TELNET_ACTIVE == "" ]]; then
|
||||
fi
|
||||
else
|
||||
NC_CMD="nc -t 127.0.0.1 $TELNET_PORT"
|
||||
echo -n shutdown | $NC_CMD > /dev/null
|
||||
echo shutdown | $NC_CMD
|
||||
|
||||
echo "Stopped server $SERVER_NAME"
|
||||
if [[ $SERVER_STARTUP_NOTIFY != "" ]]; then
|
||||
@@ -23,8 +23,19 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
# make really sure to kill server
|
||||
echo "Making sure to stop server by its PID"
|
||||
kill `cat server.pid`
|
||||
sleep 5
|
||||
# Wait for server to die; if it doesn't, kill it after a timeout
|
||||
KILL_TIMEOUT_IN_SECONDS=10
|
||||
SERVER_PID=`cat server.pid`
|
||||
seconds_counter=$KILL_TIMEOUT_IN_SECONDS
|
||||
while ((seconds_counter-- != 0)); do
|
||||
if [ ! -d /proc/$SERVER_PID ]; then
|
||||
echo "Server successfully and gracefully stopped by OSGi shutdown command."
|
||||
rm server.pid
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "Server didn't die within ${KILL_TIMEOUT_IN_SECONDS}s after sending it the shutdown command. Killing..."
|
||||
kill $SERVER_PID
|
||||
rm server.pid
|
||||
|
||||
Reference in new issue
Block a user