diff --git a/README.md b/README.md index 552b4fe1..726e2160 100644 --- a/README.md +++ b/README.md @@ -1051,6 +1051,12 @@ simplified by environment variables: - `-e TUNE_NURSERY_SIZES=TRUE` : configures nursery sizes where the initial size is 50% of the `MAX_MEMORY` and the max size is 80%. +### Enable Remote JMX for Profiling + +To enable remote JMX, such as for profiling with VisualVM or JMC, add the environment variable `ENABLE_JMX=true` and add a port forwarding of TCP port 7091, such as: + + -e ENABLE_JMX=true -p 7091:7091 + ### HTTP Proxy You may configure the use of an HTTP/HTTPS proxy by passing the proxy's URL via the `PROXY` diff --git a/start-minecraftFinalSetup b/start-minecraftFinalSetup index 309b51d4..753456c1 100644 --- a/start-minecraftFinalSetup +++ b/start-minecraftFinalSetup @@ -113,6 +113,21 @@ if isTrue ${TUNE_NURSERY_SIZES}; then JVM_XX_OPTS="${JVM_XX_OPTS} -Xmns${NURSERY_MINIMUM}M -Xmnx${NURSERY_MAXIMUM}M" fi +if isTrue ${ENABLE_JMX}; then + : ${JMX_HOST:=0.0.0.0} + : ${JMX_PORT:=7091} + JVM_OPTS="${JVM_OPTS} + -Dcom.sun.management.jmxremote.local.only=false + -Dcom.sun.management.jmxremote.port=${JMX_PORT} + -Dcom.sun.management.jmxremote.rmi.port=${JMX_PORT} + -Dcom.sun.management.jmxremote.authenticate=false + -Dcom.sun.management.jmxremote.ssl=false + -Dcom.sun.management.jmxremote.host=${JMX_HOST} + -Djava.rmi.server.hostname=${JMX_HOST}" + + log "JMX is enabled. Make sure you have port forwarding for ${JMX_PORT}" +fi + mcServerRunnerArgs="--stop-duration 60s" if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then