From 93760be4491a8214cea74b5c5e7e18986967c198 Mon Sep 17 00:00:00 2001 From: Moritz Kiemer Date: Fri, 10 Jan 2025 11:25:27 +0100 Subject: [PATCH] jaeger init: be more aggressive when stopping Change-Id: I90b7dcc7f69197b53d13093f12c9cf3ad3e9ce7e --- omd/packages/jaeger/skel/etc/init.d/jaeger | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/omd/packages/jaeger/skel/etc/init.d/jaeger b/omd/packages/jaeger/skel/etc/init.d/jaeger index 4cae1856001..70e831c3b28 100755 --- a/omd/packages/jaeger/skel/etc/init.d/jaeger +++ b/omd/packages/jaeger/skel/etc/init.d/jaeger @@ -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) @@ -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