From 487a66a75f40cc82bd40fd73e6be0bf6d33f9321 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 14 Jan 2016 10:30:28 +0000 Subject: [PATCH] Resend SIGTERM if app is still running 30 seconds after first attempt Previously, the default launch script would send SIGTERM once and then wait for up to 60 seconds for the app to have stopped. If the service was stopped immediately after being started the first SIGTERM would occasionally be ignored (presumably because the JVM was not yet in a state to handle it) causing the service stop request to fail. This commit updates the launch script to resend SIGTERM to the process if it's still running 30 seconds after the first SIGTERM was sent. Closes gh-4941 --- .../org/springframework/boot/loader/tools/launch.script | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script index ff5af74c62..b7877fb0ef 100755 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script @@ -182,8 +182,9 @@ stop() { do_stop() { kill "$1" &> /dev/null || { echoRed "Unable to kill process $1"; return 1; } - for _ in $(seq 1 60); do + for i in $(seq 1 60); do isRunning "$1" || { echoGreen "Stopped [$1]"; rm -f "$2"; return 0; } + [[ $i -eq 30 ]] && kill "$1" &> /dev/null sleep 1 done echoRed "Unable to kill process $1";