Merge pull request #7171 from lucassaldanha/gh-7121

* pr/7171:
  Make stop wait time in the launch script configurable
pull/7718/merge
Phillip Webb 8 years ago
commit 30ea1338de

@ -634,6 +634,10 @@ for Gradle and to `${project.name}` for Maven.
|`useStartStopDaemon`
|If the `start-stop-daemon` command, when it's available, should be used to control the
process. Defaults to `true`.
|`stopWaitTime`
|The default value for `STOP_WAIT_TIME`. Only valid for an `init.d` service.
Defaults to 60 seconds.
|===
@ -694,6 +698,10 @@ The following environment properties are supported with the default script:
|`DEBUG`
|if not empty will set the `-x` flag on the shell process, making it easy to see the logic
in the script.
|`STOP_WAIT_TIME`
|The time in seconds to wait when stopping the application before forcing a shutdown
(`60` by default).
|===
NOTE: The `PID_FOLDER`, `LOG_FOLDER` and `LOG_FILENAME` variables are only valid for an

@ -73,6 +73,9 @@ fi
# Initialize log file name if not provided by the config file
[[ -z "$LOG_FILENAME" ]] && LOG_FILENAME="{{logFilename:${identity}.log}}"
# Initialize stop wait time if not provided by the config file
[[ -z "$STOP_WAIT_TIME" ]] && STOP_WAIT_TIME={{stopWaitTime:60}}
# ANSI Colors
echoRed() { echo $'\e[0;31m'"$1"$'\e[0m'; }
echoGreen() { echo $'\e[0;32m'"$1"$'\e[0m'; }
@ -191,9 +194,9 @@ stop() {
do_stop() {
kill "$1" &> /dev/null || { echoRed "Unable to kill process $1"; return 1; }
for i in $(seq 1 60); do
for i in $(seq 1 $STOP_WAIT_TIME); do
isRunning "$1" || { echoGreen "Stopped [$1]"; rm -f "$2"; return 0; }
[[ $i -eq 30 ]] && kill "$1" &> /dev/null
[[ $i -eq STOP_WAIT_TIME/2 ]] && kill "$1" &> /dev/null
sleep 1
done
echoRed "Unable to kill process $1";

@ -111,6 +111,11 @@ public class DefaultLaunchScriptTests {
assertThatPlaceholderCanBeReplaced("confFolder");
}
@Test
public void stopWaitTimeCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("stopWaitTime");
}
@Test
public void defaultForUseStartStopDaemonIsTrue() throws Exception {
DefaultLaunchScript script = new DefaultLaunchScript(null, null);
@ -125,6 +130,13 @@ public class DefaultLaunchScriptTests {
assertThat(content).contains("MODE=\"auto\"");
}
@Test
public void defaultForStopWaitTimeIs60() throws Exception {
DefaultLaunchScript script = new DefaultLaunchScript(null, null);
String content = new String(script.toByteArray());
assertThat(content).contains("STOP_WAIT_TIME=60");
}
@Test
public void loadFromFile() throws Exception {
File file = this.temporaryFolder.newFile();

Loading…
Cancel
Save