From 36a0c2cccefa36832321a3ded780742b2e6d7eb1 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Tue, 29 Oct 2024 09:14:01 +0100 Subject: [PATCH] Allow setting java_opts only (#343) * Allow setting java_opts only This PR allows users to not use java_xmx, java_xms, java_maxmetaspacesize, but add all Java Options to java_opts instead. fixes: 342 Signed-off-by: Martin Alfke * Fix closing quotes Signed-off-by: Martin Alfke * Use individual or generic java opts in domain conf - fix handling of Array java_opts in standalone conf Signed-off-by: Martin Alfke * Fix variable name Signed-off-by: Martin Alfke * Update REFERENCE.md Signed-off-by: Martin Alfke * Update README regarding parameter change Signed-off-by: Martin Alfke * Typo in README Signed-off-by: Martin Alfke * Switch behavior - reenable default values - check in template if parameter is set to empty string Signed-off-by: Martin Alfke * Remove unneeded toc line Signed-off-by: Martin Alfke --------- Signed-off-by: Martin Alfke --- templates/domain.conf.epp | 11 ++++++++++- templates/standalone.conf.epp | 17 +++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/templates/domain.conf.epp b/templates/domain.conf.epp index 6a73621..1087ae3 100644 --- a/templates/domain.conf.epp +++ b/templates/domain.conf.epp @@ -42,7 +42,16 @@ fi # Specify options to pass to the Java VM. # if [ "x$JAVA_OPTS" = "x" ]; then - JAVA_OPTS="-Xms<%= $wildfly::java_xms %> -Xmx<%= $wildfly::java_xmx %> -XX:MaxMetaspaceSize=<%= $wildfly::java_maxmetaspace_size %>" + JAVA_OPTS=$JAVA_OPTS" +<%- unless $wildfly::java_xms == '' { -%> + JAVA_OPTS="$JAVA_OPTS -Xms <%= $wildfly::java_xms %>" +<%- } -%> +<%- unless $wildfly::java_xmx == '' { -%> + JAVA_OPTS="$JAVA_OPTS -Xmx <%= $wildfly::java_xmx %>" +<%- } -%> +<%- unless $wildfly::java_maxmetaspace_size == '' { -%> + JAVA_OPTS="$JAVA_OPTS -XX:MaxMetaspaceSize=<%= $wildfly::java_maxmetaspace_size %>" +<%- } -%> JAVA_OPTS="$JAVA_OPTS <% if $wildfly::java_opts =~ Array { -%> <%= $wildfly::java_opts.join(" ") -%> <% } elsif $wildfly::java_opts =~ String { -%> diff --git a/templates/standalone.conf.epp b/templates/standalone.conf.epp index 7041fe5..859ce9f 100644 --- a/templates/standalone.conf.epp +++ b/templates/standalone.conf.epp @@ -47,8 +47,21 @@ fi # Specify options to pass to the Java VM. # if [ "x$JAVA_OPTS" = "x" ]; then - JAVA_OPTS="-Xms<%= $wildfly::java_xms %> -Xmx<%= $wildfly::java_xmx %> -XX:MaxMetaspaceSize=<%= $wildfly::java_maxmetaspace_size %>" - JAVA_OPTS="$JAVA_OPTS <%= $wildfly::java_opts %>" + JAVA_OPTS="$JAVA_OPTS" +<%- unless $wildfly::java_xms == '' { -%> + JAVA_OPTS="$JAVA_OPTS -Xms<%= $wildfly::java_xms %>" +<%- } -%> +<%- unless $wildfly::java_xmx == '' { -%> + JAVA_OPTS="$JAVA_OPTS -Xmx<%= $wildfly::java_xmx %>" +<%- } -%> +<%- unless $wildfly::java_maxmetaspace_size == '' { -%> + JAVA_OPTS="$JAVA_OPTS -XX:MaxMetaspaceSize=<%= $wildfly::java_maxmetaspace_size %>" +<%- } -%> + JAVA_OPTS="$JAVA_OPTS <% if $wildfly::java_opts =~ Array { -%> +<%= $wildfly::java_opts.join(" ") -%> +<% } elsif $wildfly::java_opts =~ String { -%> +<%= $wildfly::java_opts -%> +<% } -%>" else echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS" fi