From 5c11059e1db097c8743ec03fed5f5fc8f02a81eb Mon Sep 17 00:00:00 2001 From: Christian Koops Date: Thu, 27 Oct 2016 10:36:29 +0200 Subject: [PATCH] Make launch script's logFilename and pidFilename configurable via properties Closes gh-7234 --- spring-boot-docs/src/main/asciidoc/deployment.adoc | 7 +++++++ .../springframework/boot/loader/tools/launch.script | 5 ++--- .../boot/loader/tools/DefaultLaunchScriptTests.java | 10 ++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/spring-boot-docs/src/main/asciidoc/deployment.adoc b/spring-boot-docs/src/main/asciidoc/deployment.adoc index 2c2f060d4e..058e0b0e7b 100644 --- a/spring-boot-docs/src/main/asciidoc/deployment.adoc +++ b/spring-boot-docs/src/main/asciidoc/deployment.adoc @@ -617,9 +617,16 @@ for Gradle and to `${project.name}` for Maven. |`logFolder` |The default value for `LOG_FOLDER`. Only valid for an `init.d` service. +|`logFilename` +|The default value for `LOG_FILENAME`. Only valid for an `init.d` service. + |`pidFolder` |The default value for `PID_FOLDER`. Only valid for an `init.d` service. +|`pidFilename` +|The default value for the name of the pid file in `PID_FOLDER`. Only valid for an + `init.d` service. + |`useStartStopDaemon` |If the `start-stop-daemon` command, when it's available, should be used to control the process. Defaults to `true`. 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 f2fca2c793..7b78c1f27c 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 @@ -71,8 +71,7 @@ if [[ -z "$identity" ]]; then fi # Initialize log file name if not provided by the config file -[[ -z "$LOG_FILENAME" ]] && LOG_FILENAME="${identity}.log" - +[[ -z "$LOG_FILENAME" ]] && LOG_FILENAME="{{logFilename:${identity}.log}}" # ANSI Colors echoRed() { echo $'\e[0;31m'"$1"$'\e[0m'; } @@ -114,7 +113,7 @@ if [[ "$identity" == "$init_script" ]] || [[ "$identity" == "$APP_NAME" ]]; then PID_FOLDER="$PID_FOLDER/${identity}" pid_subfolder=$PID_FOLDER fi -pid_file="$PID_FOLDER/${identity}.pid" +pid_file="$PID_FOLDER/{{pidFilename:${identity}.pid}}" log_file="$LOG_FOLDER/$LOG_FILENAME" # Determine the user to run as if we are root diff --git a/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/DefaultLaunchScriptTests.java b/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/DefaultLaunchScriptTests.java index ba1e2dd0bb..d7491ff52b 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/DefaultLaunchScriptTests.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/DefaultLaunchScriptTests.java @@ -46,6 +46,16 @@ public class DefaultLaunchScriptTests { assertThat(content).contains("Spring Boot Startup Script"); } + @Test + public void logFilenameCanBeReplaced() throws Exception { + assertThatPlaceholderCanBeReplaced("logFilename"); + } + + @Test + public void pidFilenameCanBeReplaced() throws Exception { + assertThatPlaceholderCanBeReplaced("pidFilename"); + } + @Test public void initInfoProvidesCanBeReplaced() throws Exception { assertThatPlaceholderCanBeReplaced("initInfoProvides");