From 1e77b81b32003bc45ce142954f5e63e07c187e29 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 19 Jul 2026 20:37:26 -0500 Subject: [PATCH] Allow for custom SERVER_RUNNER (#4182) --- docs/configuration/misc-options.md | 4 ++++ scripts/start-finalExec | 15 ++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/configuration/misc-options.md b/docs/configuration/misc-options.md index b623ba8e..31d6771f 100644 --- a/docs/configuration/misc-options.md +++ b/docs/configuration/misc-options.md @@ -202,6 +202,10 @@ Be sure to also increase the shutdown timeout described [here for docker compose If you are using a host-attached data directory, then you can have the image setup the Minecraft server files and stop prior to launching the server process by setting `SETUP_ONLY` to `true`. +## Custom server runner + +By default, the image finishes startup by exec'ing [mc-server-runner](https://github.com/itzg/mc-server-runner) to run the Minecraft server itself. This can be replaced by setting the environment variable `SERVER_RUNNER`. The arguments passed will start with ones specific to mc-server-runner, followed by `--`, and then the actual `java -jar` arguments or equivalent server entry script, such as `run.sh` for Forge. + ## Enable Flare Flags To enable the JVM flags required to fully support the [Flare profiling suite](https://blog.airplane.gg/flare), set the following variable: diff --git a/scripts/start-finalExec b/scripts/start-finalExec index daf019f2..e0ad742e 100755 --- a/scripts/start-finalExec +++ b/scripts/start-finalExec @@ -3,6 +3,7 @@ : "${DEBUG_EXEC:=false}" : "${SETUP_ONLY:=false}" : "${CUSTOM_JAR_EXEC:=}" +: "${SERVER_RUNNER:=mc-server-runner}" # shellcheck source=start-utils . "$(dirname "$0")/start-utils" @@ -96,7 +97,7 @@ fi if versionLessThan 1.7; then : # No patch required here. elif versionLessThan 1.18.1; then - if isTrue ${SKIP_LOG4J_PATCHER:-false}; then + if isTrue "${SKIP_LOG4J_PATCHER:-false}"; then log "Skipping Log4jPatcher, make sure you are not affected" else JVM_OPTS="-javaagent:/image/Log4jPatcher.jar ${JVM_OPTS}" @@ -496,7 +497,7 @@ if [[ ${TYPE} == "CURSEFORGE" && "${SERVER}" ]]; then if isTrue "${DEBUG_EXEC}"; then set -x fi - exec mc-server-runner ${bootstrapArgs} "${mcServerRunnerArgs[@]}" java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar "$(basename "${SERVER}")" "$@" $EXTRA_ARGS + exec "${SERVER_RUNNER}" ${bootstrapArgs} "${mcServerRunnerArgs[@]}" -- java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar "$(basename "${SERVER}")" "$@" $EXTRA_ARGS elif [[ ${TYPE} == "CURSEFORGE" ]]; then mcServerRunnerArgs+=(--shell bash) @@ -550,18 +551,18 @@ fi JVM_ARGS=${JVM_ARGS//$'\n'/} sed -i "s~JAVA_ARGS=.*~JAVA_ARGS=\"${JVM_ARGS}\"~" "${FTB_DIR}/variables.txt" fi - exec mc-server-runner "${mcServerRunnerArgs[@]}" "${finalArgs[@]}" + exec "${SERVER_RUNNER}" "${mcServerRunnerArgs[@]}" -- "${finalArgs[@]}" elif [[ $SERVER =~ run.sh ]]; then log "Using Forge supplied run.sh script..." echo $JVM_XX_OPTS $JVM_OPTS $expandedDOpts > user_jvm_args.txt - if isTrue ${SETUP_ONLY}; then + if isTrue "${SETUP_ONLY}"; then echo "SETUP_ONLY: bash ${SERVER}" exit fi if isTrue "${DEBUG_EXEC}"; then set -x fi - exec mc-server-runner "${mcServerRunnerArgs[@]}" --shell bash "${SERVER}" $EXTRA_ARGS + exec "${SERVER_RUNNER}" "${mcServerRunnerArgs[@]}" --shell bash -- "${SERVER}" $EXTRA_ARGS else # If we have a bootstrap.txt file... feed that in to the server stdin if [ -f $bootstrapPath ]; then @@ -590,7 +591,7 @@ else "$@" $EXTRA_ARGS ) - if isTrue ${SETUP_ONLY}; then + if isTrue "${SETUP_ONLY}"; then echo "SETUP_ONLY: java ${finalArgs[*]}" exit fi @@ -599,5 +600,5 @@ else set -x fi - exec mc-server-runner ${bootstrapArgs} "${mcServerRunnerArgs[@]}" java "${finalArgs[@]}" + exec "${SERVER_RUNNER}" ${bootstrapArgs} "${mcServerRunnerArgs[@]}" -- java "${finalArgs[@]}" fi