Skip to content

Commit 24f8c73

Browse files
committed
Make relative PID_FOLDER and LOG_FOLDER absolute using jar's directory
Closes gh-7092 Closes gh-7093
1 parent 03deff9 commit 24f8c73

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,12 @@ public void launchWithRelativePidFolder() throws Exception {
207207
coloredString(AnsiColor.GREEN, "Running [" + extractPid(output) + "]"));
208208
assertThat(output).has(
209209
coloredString(AnsiColor.GREEN, "Stopped [" + extractPid(output) + "]"));
210+
}
210211

212+
@Test
213+
public void launchWithRelativeLogFolder() throws Exception {
214+
String output = doTest("launch-with-relative-log-folder.sh");
215+
assertThat(output).contains("Log written");
211216
}
212217

213218
private void doLaunch(String script) throws Exception {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
source ./test-functions.sh
2+
mkdir ./pid
3+
install_service
4+
echo 'LOG_FOLDER=log' > /test-service/spring-boot-app.conf
5+
mkdir -p /test-service/log
6+
start_service
7+
await_app
8+
[[ -s /test-service/log/spring-boot-app.log ]] && echo "Log written"

spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-relative-pid-folder.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
source ./test-functions.sh
2-
mkdir ./pid
32
install_service
4-
echo 'PID_FOLDER=./pid' > /test-service/spring-boot-app.conf
3+
mkdir /test-service/pid
4+
echo 'PID_FOLDER=pid' > /test-service/spring-boot-app.conf
55
start_service
66
echo "PID: $(cat /test-service/pid/spring-boot-app/spring-boot-app.pid)"
77
await_app

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ configfile="$(basename "${jarfile%.*}.conf")"
5252
# Initialize PID/LOG locations if they weren't provided by the config file
5353
[[ -z "$PID_FOLDER" ]] && PID_FOLDER="{{pidFolder:/var/run}}"
5454
[[ -z "$LOG_FOLDER" ]] && LOG_FOLDER="{{logFolder:/var/log}}"
55+
! [[ "$PID_FOLDER" == /* ]] && PID_FOLDER="$(dirname "$jarfile")"/"$PID_FOLDER"
56+
! [[ "$LOG_FOLDER" == /* ]] && LOG_FOLDER="$(dirname "$jarfile")"/"$LOG_FOLDER"
5557
! [[ -x "$PID_FOLDER" ]] && PID_FOLDER="/tmp"
5658
! [[ -x "$LOG_FOLDER" ]] && LOG_FOLDER="/tmp"
5759

0 commit comments

Comments
 (0)