Skip to content

Commit

Permalink
jaeger init: be more aggressive when stopping
Browse files Browse the repository at this point in the history
Change-Id: I90b7dcc7f69197b53d13093f12c9cf3ad3e9ce7e
  • Loading branch information
mo-ki committed Jan 14, 2025
1 parent 082a0a9 commit 93760be
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions omd/packages/jaeger/skel/etc/init.d/jaeger
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ process_is_running() {
kill -0 "$1" 2>/dev/null 2>&1
}

await_process_stop() {
max=$(("${1}" * 10))
for N in $(seq "${max}"); do
process_is_running "$2" || return 0
[ $((N % 10)) -eq 0 ] && printf "."
sleep 0.1
done
return 1
}

case "$1" in
start)
Expand Down Expand Up @@ -49,19 +58,17 @@ case "$1" in
echo -n "killing $THE_PID..."
if kill "$THE_PID" 2>/dev/null; then
# Only wait for pidfile removal when the signal could be sent
N=0
while [ -e "$PIDFILE" ] && process_is_running "$THE_PID"; do
sleep 0.05
if [ $((N % 20)) -eq 0 ]; then
echo -n .
fi
N=$((N + 1))
if [ $N -gt 600 ]; then
echo "process did not terminate."
exit 1
fi
done
if ! await_process_stop 60 "$THE_PID"; then
kill -9 "$THE_PID" 2>/dev/null
await_process_stop 10 "$THE_PID"
fi
fi

if process_is_running; then
echo "process did not terminate."
exit 1
fi

rm -f "$PIDFILE"
echo 'OK'
fi
Expand Down

0 comments on commit 93760be

Please sign in to comment.