Add Feature configuration and support for dynamic feature toggling in ForgeSettings with system property and config precedence. Add unit tests, documentation, and integrate feature handling across the project.
This commit is contained in:
1 parent
07dc3f0fad
commit
607d5b2b32
7 files changed
+255
-44
No files matched your search
@@ -49,6 +49,11 @@
|
||||
# Maintenance
|
||||
# SOFT_RESET true: start in Project Zomboid's soft reset mode (-Dsoftreset).
|
||||
# Intended for a single start; unset it afterwards.
|
||||
#
|
||||
# ZomboidForge features (also /forge/forge.toml [features]; a set variable takes precedence)
|
||||
# ZF_EXPERIMENTAL_PERFORMANCE
|
||||
# true/false: performance changes that alter timing or resource use
|
||||
# (more threads, shorter waits). Default: false
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
@@ -86,6 +91,9 @@ readonly SERVER_DB="${DATA_DIR}/db/${SERVER_NAME}.db"
|
||||
# Target of the /opt/pz/steamapps symlink; Steam stores Workshop downloads there.
|
||||
readonly STEAMAPPS_DIR="${DATA_DIR}/steamapps"
|
||||
readonly CGROUP_MEMORY_MAX="/sys/fs/cgroup/memory.max"
|
||||
# Keys of the ZomboidForge features (core/config/Feature): ZF_<KEY> becomes
|
||||
# -Dzomboidforge.features.<key>.
|
||||
readonly FEATURES=(experimental_performance)
|
||||
readonly UNLIMITED_MAX_HEAP="8g"
|
||||
|
||||
log() {
|
||||
@@ -272,6 +280,30 @@ default_max_heap() {
|
||||
echo "$(( limit * 3 / 4 / 1024 / 1024 ))m"
|
||||
}
|
||||
|
||||
# Appends -Dzomboidforge.features.<key>=true|false for every feature whose ZF_<KEY> is set.
|
||||
# Unset or empty: no property, so forge.toml or the default (off) decides.
|
||||
add_feature_properties() {
|
||||
local key
|
||||
local variable
|
||||
local value
|
||||
|
||||
for key in "${FEATURES[@]}"; do
|
||||
variable="ZF_${key^^}"
|
||||
value="${!variable:-}"
|
||||
|
||||
if [[ -z "${value}" ]]; then
|
||||
continue
|
||||
fi
|
||||
if is_true "${value}"; then
|
||||
jvm_args+=("-Dzomboidforge.features.${key}=true")
|
||||
elif is_false "${value}"; then
|
||||
jvm_args+=("-Dzomboidforge.features.${key}=false")
|
||||
else
|
||||
fail "${variable} must be true or false, got '${value}'."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Same JVM setup as the vanilla ProjectZomboid64.json and start-server.sh.
|
||||
# Java runs directly instead of through the native ProjectZomboid64 launcher.
|
||||
build_jvm_args() {
|
||||
@@ -308,6 +340,7 @@ build_jvm_args() {
|
||||
log "SOFT_RESET is set: starting in soft reset mode. Unset it for the next start."
|
||||
jvm_args+=("-Dsoftreset")
|
||||
fi
|
||||
add_feature_properties
|
||||
}
|
||||
|
||||
build_server_args() {
|
||||
|
||||
Reference in new issue
Block a user