Allow for custom SERVER_RUNNER (#4182)

This commit is contained in:
Geoff Bourne
2026-07-19 20:37:26 -05:00
committed by GitHub
parent 479973c950
commit 1e77b81b32
2 changed files with 12 additions and 7 deletions
+4
View File
@@ -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:
+8 -7
View File
@@ -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