mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-08-30 18:57:15 +00:00
@@ -1288,7 +1288,9 @@ The values of all three are passed directly to the JVM and support format/units
|
|||||||
|
|
||||||
-e MEMORY=2G
|
-e MEMORY=2G
|
||||||
|
|
||||||
> NOTE: the settings above only set the Java **heap** limits. Memory resource requests and limits on the overall container should also account for non-heap memory usage. An extra 25% is [a general best practice](https://dzone.com/articles/best-practices-java-memory-arguments-for-container).
|
> To let the JVM calculate the heap size from the container declared memory limit, unset `MEMORY` with an empty value, such as `-e MEMORY=""`.
|
||||||
|
|
||||||
|
> The settings above only set the Java **heap** limits. Memory resource requests and limits on the overall container should also account for non-heap memory usage. An extra 25% is [a general best practice](https://dzone.com/articles/best-practices-java-memory-arguments-for-container).
|
||||||
|
|
||||||
### JVM Options
|
### JVM Options
|
||||||
|
|
||||||
|
|||||||
+16
-8
@@ -70,8 +70,8 @@ if [[ ${GUI} = false || ${GUI} = FALSE ]]; then
|
|||||||
EXTRA_ARGS+=" nogui"
|
EXTRA_ARGS+=" nogui"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# put these prior JVM_OPTS at the end to give any memory settings there higher precedence
|
: "${INIT_MEMORY:=${MEMORY}}"
|
||||||
log "Setting initial memory to ${INIT_MEMORY:=${MEMORY}} and max to ${MAX_MEMORY:=${MEMORY}}"
|
: "${MAX_MEMORY:=${MEMORY}}"
|
||||||
|
|
||||||
expandedDOpts=
|
expandedDOpts=
|
||||||
if [ -n "$JVM_DD_OPTS" ]; then
|
if [ -n "$JVM_DD_OPTS" ]; then
|
||||||
@@ -157,7 +157,15 @@ if isTrue "${DEBUG_MEMORY}"; then
|
|||||||
free -m
|
free -m
|
||||||
fi
|
fi
|
||||||
|
|
||||||
JVM_OPTS="-Xms${INIT_MEMORY} -Xmx${MAX_MEMORY} ${JVM_OPTS}"
|
if [[ ${INIT_MEMORY} || ${MAX_MEMORY} ]]; then
|
||||||
|
log "Setting initial memory to ${INIT_MEMORY:=${MEMORY}} and max to ${MAX_MEMORY:=${MEMORY}}"
|
||||||
|
if [[ ${INIT_MEMORY} ]]; then
|
||||||
|
JVM_OPTS="-Xms${INIT_MEMORY} ${JVM_OPTS}"
|
||||||
|
fi
|
||||||
|
if [[ ${MAX_MEMORY} ]]; then
|
||||||
|
JVM_OPTS="-Xmx${MAX_MEMORY} ${JVM_OPTS}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
function copyFilesForCurseForge() {
|
function copyFilesForCurseForge() {
|
||||||
# copy player modification files unconditionally since their
|
# copy player modification files unconditionally since their
|
||||||
@@ -197,11 +205,11 @@ elif [[ ${TYPE} == "CURSEFORGE" ]]; then
|
|||||||
cat > "${FTB_DIR}/settings-local.sh" <<EOF
|
cat > "${FTB_DIR}/settings-local.sh" <<EOF
|
||||||
export MIN_RAM="${INIT_MEMORY}"
|
export MIN_RAM="${INIT_MEMORY}"
|
||||||
export MAX_RAM="${MAX_MEMORY}"
|
export MAX_RAM="${MAX_MEMORY}"
|
||||||
export JAVA_PARAMETERS="${JVM_XX_OPTS} -Xms${INIT_MEMORY} ${JVM_OPTS} $expandedDOpts"
|
export JAVA_PARAMETERS="${JVM_XX_OPTS} ${JVM_OPTS} $expandedDOpts"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# patch CurseForge cfg file, if present
|
# patch CurseForge cfg file, if present
|
||||||
if [ -f "${FTB_DIR}/settings.cfg" ]; then
|
if [ -f "${FTB_DIR}/settings.cfg" ] && [[ ${MAX_MEMORY} ]]; then
|
||||||
sed -i "s/MAX_RAM=[^;]*/MAX_RAM=${MAX_MEMORY}/" "${FTB_DIR}/settings.cfg"
|
sed -i "s/MAX_RAM=[^;]*/MAX_RAM=${MAX_MEMORY}/" "${FTB_DIR}/settings.cfg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -210,7 +218,7 @@ EOF
|
|||||||
|
|
||||||
finalArgs="${FTB_SERVER_START}"
|
finalArgs="${FTB_SERVER_START}"
|
||||||
|
|
||||||
if isTrue ${SETUP_ONLY:=false}; then
|
if isTrue "${SETUP_ONLY:=false}"; then
|
||||||
echo "SETUP_ONLY: ${finalArgs}"
|
echo "SETUP_ONLY: ${finalArgs}"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
@@ -248,11 +256,11 @@ else
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if isTrue ${DEBUG_EXEC}; then
|
if isTrue "${DEBUG_EXEC}"; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if isTrue ${EXEC_DIRECTLY:-false}; then
|
if isTrue "${EXEC_DIRECTLY:-false}"; then
|
||||||
exec java "${finalArgs[@]}"
|
exec java "${finalArgs[@]}"
|
||||||
else
|
else
|
||||||
exec mc-server-runner ${bootstrapArgs} "${mcServerRunnerArgs[@]}" java "${finalArgs[@]}"
|
exec mc-server-runner ${bootstrapArgs} "${mcServerRunnerArgs[@]}" java "${finalArgs[@]}"
|
||||||
|
|||||||
Reference in New Issue
Block a user