mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Always handle quoted arguments correctly in the launch script
Previously, arguments passed to the script were handled in one way if a service was being started using start-stop-daemon and in another way if start-stop-daemon wasn’t available or the application is being launched in run mode. This meant that quoted arguments were only handled correctly when the application was being started using start-stop-daemon. This commit updates the launch script so that argument handling is the same across all three different way that the application can be launched. Closes gh-5942
This commit is contained in:
parent
e561cc1997
commit
4c65e5e704
@ -126,8 +126,7 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build actual command to execute
|
||||
command="$javaexe -Dsun.misc.URLClassPath.disableJarChecking=true $JAVA_OPTS -jar $jarfile $RUN_ARGS $*"
|
||||
arguments=(-Dsun.misc.URLClassPath.disableJarChecking=true $JAVA_OPTS -jar $jarfile $RUN_ARGS "$@")
|
||||
|
||||
# Action functions
|
||||
start() {
|
||||
@ -148,7 +147,6 @@ do_start() {
|
||||
chown "$run_user" "$pid_file"
|
||||
chown "$run_user" "$log_file"
|
||||
if [ $USE_START_STOP_DAEMON = true ] && type start-stop-daemon > /dev/null 2>&1; then
|
||||
arguments=(-Dsun.misc.URLClassPath.disableJarChecking=true $JAVA_OPTS -jar $jarfile $RUN_ARGS "$@")
|
||||
start-stop-daemon --start --quiet \
|
||||
--chuid "$run_user" \
|
||||
--name "$identity" \
|
||||
@ -160,12 +158,12 @@ do_start() {
|
||||
>> "$log_file" 2>&1
|
||||
await_file "$pid_file"
|
||||
else
|
||||
su -s /bin/sh -c "$command >> \"$log_file\" 2>&1 & echo \$!" "$run_user" > "$pid_file"
|
||||
su -s /bin/sh -c "$javaexe $(printf "\"%s\" " "${arguments[@]}") >> \"$log_file\" 2>&1 & echo \$!" "$run_user" > "$pid_file"
|
||||
fi
|
||||
pid=$(cat "$pid_file")
|
||||
else
|
||||
checkPermissions || return $?
|
||||
$command >> "$log_file" 2>&1 &
|
||||
"$javaexe" "${arguments[@]}" >> "$log_file" 2>&1 &
|
||||
pid=$!
|
||||
disown $pid
|
||||
echo "$pid" > "$pid_file"
|
||||
@ -215,7 +213,7 @@ status() {
|
||||
|
||||
run() {
|
||||
pushd "$(dirname "$jarfile")" > /dev/null
|
||||
$command
|
||||
"$javaexe" "${arguments[@]}"
|
||||
result=$?
|
||||
popd > /dev/null
|
||||
return "$result"
|
||||
|
Loading…
Reference in New Issue
Block a user