Skip to content

Commit 2b9e091

Browse files
Junji Shimagakinoorul
authored andcommitted
fix(bin): make sure that PID is valid and process ended by server_stop.sh (spark-jobserver#850)
* Remove the PID file in case the mentioned process does not exist * Make sure that the process terminated after kill-process-tree.sh
1 parent 86ced18 commit 2b9e091

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

bin/server_stop.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,22 @@ fi
1919

2020
pidFilePath=$appdir/$PIDFILE
2121

22-
if [ ! -f "$pidFilePath" ] || ! kill -0 "$(cat "$pidFilePath")"; then
23-
echo 'Job server not running'
22+
if [ ! -f "$pidFilePath" ]; then
23+
echo 'Job server not running'
2424
else
25-
echo 'Stopping job server...'
2625
PID="$(cat "$pidFilePath")"
27-
"$(dirname "$0")"/kill-process-tree.sh 15 $PID && rm "$pidFilePath"
28-
echo '...job server stopped'
26+
if ! kill -0 $PID; then
27+
echo "PID file exists but the process $PID does not exist. Removing $pidFilePath"
28+
rm "$pidFilePath"
29+
else
30+
echo 'Stopping job server...'
31+
"$(dirname "$0")"/kill-process-tree.sh 15 $PID
32+
if ! kill -0 $PID 2> /dev/null ; then
33+
echo '...job server stopped'
34+
rm "$pidFilePath"
35+
else
36+
echo '...?? job server is still running'
37+
fi
38+
fi
2939
fi
3040

31-
32-

0 commit comments

Comments
 (0)