Skip to content

Commit 4a222cb

Browse files
committed
Polish "Log a warning when using fallback for pid and log locations"
Closes gh-14519
1 parent 3f894cb commit 4a222cb

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ echoYellow() { echo $'\e[0;33m'"$1"$'\e[0m'; }
6767
[[ -z "$LOG_FOLDER" ]] && LOG_FOLDER="{{logFolder:/var/log}}"
6868
! [[ "$PID_FOLDER" == /* ]] && PID_FOLDER="$(dirname "$jarfile")"/"$PID_FOLDER"
6969
! [[ "$LOG_FOLDER" == /* ]] && LOG_FOLDER="$(dirname "$jarfile")"/"$LOG_FOLDER"
70-
! [[ -x "$PID_FOLDER" ]] && echoYellow "Warning: PID_FOLDER=$PID_FOLDER does not exists fallback to /tmp" && PID_FOLDER="/tmp"
71-
! [[ -x "$LOG_FOLDER" ]] && echoYellow "Warning: LOG_FOLDER=$LOG_FOLDER does not exists fallback to /tmp" && LOG_FOLDER="/tmp"
70+
! [[ -x "$PID_FOLDER" ]] && echoYellow "PID_FOLDER $PID_FOLDER does not exist. Falling back to /tmp" && PID_FOLDER="/tmp"
71+
! [[ -x "$LOG_FOLDER" ]] && echoYellow "LOG_FOLDER $LOG_FOLDER does not exist. Falling back to /tmp" && LOG_FOLDER="/tmp"
7272

7373
# Set up defaults
7474
[[ -z "$MODE" ]] && MODE="{{mode:auto}}" # modes are "auto", "service" or "run"

spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,22 @@ public void startWhenStopped() throws Exception {
171171

172172
@Test
173173
public void basicLaunch() throws Exception {
174-
doLaunch("basic-launch.sh");
174+
String output = doTest("basic-launch.sh");
175+
assertThat(output).doesNotContain("PID_FOLDER");
176+
}
177+
178+
@Test
179+
public void launchWithMissingLogFolderGeneratesAWarning() throws Exception {
180+
String output = doTest("launch-with-missing-log-folder.sh");
181+
assertThat(output).has(coloredString(AnsiColor.YELLOW,
182+
"LOG_FOLDER /does/not/exist does not exist. Falling back to /tmp"));
183+
}
184+
185+
@Test
186+
public void launchWithMissingPidFolderGeneratesAWarning() throws Exception {
187+
String output = doTest("launch-with-missing-pid-folder.sh");
188+
assertThat(output).has(coloredString(AnsiColor.YELLOW,
189+
"PID_FOLDER /does/not/exist does not exist. Falling back to /tmp"));
175190
}
176191

177192
@Test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source ./test-functions.sh
2+
install_service
3+
echo 'LOG_FOLDER=/does/not/exist' > /test-service/spring-boot-app.conf
4+
start_service
5+
await_app
6+
curl -s http://127.0.0.1:8080/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source ./test-functions.sh
2+
install_service
3+
echo 'PID_FOLDER=/does/not/exist' > /test-service/spring-boot-app.conf
4+
start_service
5+
await_app
6+
curl -s http://127.0.0.1:8080/

0 commit comments

Comments
 (0)