SevTech: Ages of the Sky

SevTech: Ages of the Sky

1M Downloads

Improvement: improved Docker support - read java settings from environment in settings.sh

Genda1ph opened this issue ยท 0 comments

commented

Context

I've recently set up a SevTech Ages server in Docker, and there's an enhancement that can be made in this regard: settings.sh can be modified to accept environment variables.

Following snippet allows to set MIN_RAM, MAX_RAM, JAVA_PARAMETERS and JAVA_PARAMETERS_EXTRA to:

  • Set -Xms and -Xmx respectively.
  • Replace default JAVA_PARAMETERS.
  • Add onto default JAVA_PARAMETERS (for example setting JAVA_PARAMETERS_EXTRA="-Dfml.queryResult=confirm").

Config/Script Details (if desired)

This is slightly more complicated than it strictly needs to be since it assumes your scripts run with errexit and nounset flags.

# Set default limits for min and max memory for JVM
export MIN_RAM="${MIN_RAM:-1024M}"
export MAX_RAM="${MAX_RAM:-4096M}"

# Allow replacing default JAVA_PARAMETERS
JAVA_PARAMETERS="${JAVA_PARAMETERS-}"
if [ -z "${JAVA_PARAMETERS}" ]; then
        JAVA_PARAMETERS="-XX:+UseG1GC -Dsun.rmi.dgc.server.gcInterval=2147483646 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -Dfml.readTimeout=180"
fi

# Allow setting extra JAVA_PARAMETERS through an environment variable
JAVA_PARAMETERS_EXTRA="${JAVA_PARAMETERS_EXTRA-}"
if [ -n "$JAVA_PARAMETERS_EXTRA" ]; then
        JAVA_PARAMETERS="$JAVA_PARAMETERS $JAVA_PARAMETERS_EXTRA"
fi