Polish "Log a warning when using fallback for pid and log locations"

Closes gh-14519
pull/14680/merge
Andy Wilkinson 6 years ago
parent 3f894cbeeb
commit 4a222cb4e5

@ -67,8 +67,8 @@ echoYellow() { echo $'\e[0;33m'"$1"$'\e[0m'; }
[[ -z "$LOG_FOLDER" ]] && LOG_FOLDER="{{logFolder:/var/log}}" [[ -z "$LOG_FOLDER" ]] && LOG_FOLDER="{{logFolder:/var/log}}"
! [[ "$PID_FOLDER" == /* ]] && PID_FOLDER="$(dirname "$jarfile")"/"$PID_FOLDER" ! [[ "$PID_FOLDER" == /* ]] && PID_FOLDER="$(dirname "$jarfile")"/"$PID_FOLDER"
! [[ "$LOG_FOLDER" == /* ]] && LOG_FOLDER="$(dirname "$jarfile")"/"$LOG_FOLDER" ! [[ "$LOG_FOLDER" == /* ]] && LOG_FOLDER="$(dirname "$jarfile")"/"$LOG_FOLDER"
! [[ -x "$PID_FOLDER" ]] && echoYellow "Warning: PID_FOLDER=$PID_FOLDER does not exists fallback to /tmp" && PID_FOLDER="/tmp" ! [[ -x "$PID_FOLDER" ]] && echoYellow "PID_FOLDER $PID_FOLDER does not exist. Falling back to /tmp" && PID_FOLDER="/tmp"
! [[ -x "$LOG_FOLDER" ]] && echoYellow "Warning: LOG_FOLDER=$LOG_FOLDER does not exists fallback to /tmp" && LOG_FOLDER="/tmp" ! [[ -x "$LOG_FOLDER" ]] && echoYellow "LOG_FOLDER $LOG_FOLDER does not exist. Falling back to /tmp" && LOG_FOLDER="/tmp"
# Set up defaults # Set up defaults
[[ -z "$MODE" ]] && MODE="{{mode:auto}}" # modes are "auto", "service" or "run" [[ -z "$MODE" ]] && MODE="{{mode:auto}}" # modes are "auto", "service" or "run"

@ -171,7 +171,22 @@ public class SysVinitLaunchScriptIT {
@Test @Test
public void basicLaunch() throws Exception { public void basicLaunch() throws Exception {
doLaunch("basic-launch.sh"); String output = doTest("basic-launch.sh");
assertThat(output).doesNotContain("PID_FOLDER");
}
@Test
public void launchWithMissingLogFolderGeneratesAWarning() throws Exception {
String output = doTest("launch-with-missing-log-folder.sh");
assertThat(output).has(coloredString(AnsiColor.YELLOW,
"LOG_FOLDER /does/not/exist does not exist. Falling back to /tmp"));
}
@Test
public void launchWithMissingPidFolderGeneratesAWarning() throws Exception {
String output = doTest("launch-with-missing-pid-folder.sh");
assertThat(output).has(coloredString(AnsiColor.YELLOW,
"PID_FOLDER /does/not/exist does not exist. Falling back to /tmp"));
} }
@Test @Test

@ -0,0 +1,6 @@
source ./test-functions.sh
install_service
echo 'LOG_FOLDER=/does/not/exist' > /test-service/spring-boot-app.conf
start_service
await_app
curl -s http://127.0.0.1:8080/

@ -0,0 +1,6 @@
source ./test-functions.sh
install_service
echo 'PID_FOLDER=/does/not/exist' > /test-service/spring-boot-app.conf
start_service
await_app
curl -s http://127.0.0.1:8080/
Loading…
Cancel
Save