From 5ffd2eee275b89418160d3d8637704aea0efb764 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 17 Jan 2017 12:54:01 +0100 Subject: [PATCH] library/roles/tomcat: Do not set the permgen max size if the JDK version is >= 8. --- tomcat-multiple-instances/templates/tomcat-default.j2 | 2 +- tomcat/defaults/main.yml | 3 ++- tomcat/templates/tomcat-default.j2 | 9 ++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tomcat-multiple-instances/templates/tomcat-default.j2 b/tomcat-multiple-instances/templates/tomcat-default.j2 index b976b2a..74ac914 100644 --- a/tomcat-multiple-instances/templates/tomcat-default.j2 +++ b/tomcat-multiple-instances/templates/tomcat-default.j2 @@ -25,6 +25,7 @@ JAVA_OPTS="{{ item.java_gc_opts }} $JAVA_OPTS" JAVA_OPTS="${JAVA_OPTS} {{ item.other_java_opts }}" {% endif %} {% if item.jmx_enabled is defined and item.jmx_enabled %} +# JMX settings JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port={{ item.jmx_port | default('tomcat_m_jmx_port') }}" {% if item.jmx_use_ssl is defined and item.jmx_use_ssl %} JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.ssl=true" @@ -42,7 +43,6 @@ JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.authenticate=false" {% if item.jmx_disable_additional_ports is defined and item.jmx_disable_additional_ports %} JAVA_OPTS="${JAVA_OPTS} -XX:+DisableAttachMechanism -Dcom.sun.management.jmxremote.rmi.port={{ item.jmx_port }}" {% endif %} - {% endif %} {% if item.remote_debugging is defined and item.remote_debugging %} # You will be able to use a java debugger on port {{ item.remote_debugging_port }}. diff --git a/tomcat/defaults/main.yml b/tomcat/defaults/main.yml index 14b0634..98eb0ab 100644 --- a/tomcat/defaults/main.yml +++ b/tomcat/defaults/main.yml @@ -10,9 +10,10 @@ tomcat_pkgs: tomcat_user: tomcat7 tomcat_max_threads: 200 tomcat_min_heap_size: 2048m +tomcat_permgen_defined: True tomcat_heap_size: '{{ tomcat_min_heap_size }}' tomcat_permgen_size: 512m -tomcat_java_opts: "-Xms{{ tomcat_min_heap_size }} -Xmx{{ tomcat_heap_size }} -XX:MaxPermSize={{ tomcat_permgen_size }}" +tomcat_java_opts: "-Xms{{ tomcat_min_heap_size }} -Xmx{{ tomcat_heap_size }}" tomcat_java_gc_opts: "-XX:+UseConcMarkSweepGC" #tomcat_other_java_opts: "-Djsse.enableSNIExtension=false" tomcat_other_java_opts: "" diff --git a/tomcat/templates/tomcat-default.j2 b/tomcat/templates/tomcat-default.j2 index 88f5d7c..02ad697 100644 --- a/tomcat/templates/tomcat-default.j2 +++ b/tomcat/templates/tomcat-default.j2 @@ -14,8 +14,15 @@ JAVA_HOME={{ jdk_java_home }} {% endif %} JAVA_OPTS="-server -Djava.awt.headless=true" +{% if jdk_default <= 7 %} +{% if tomcat_permgen_defined %} +{% if tomcat_permgen_size is defined %} +JAVA_OPTS="-XX:MaxPermSize={{ tomcat_permgen_size }} $JAVA_OPTS" +{% endif %} +{% endif %} +{% endif %} {% if tomcat_java_opts is defined %} -JAVA_OPTS="{{ tomcat_java_opts }}" +JAVA_OPTS="{{ tomcat_java_opts }} $JAVA_OPTS" {% endif %} {% if tomcat_java_gc_opts is defined %} JAVA_OPTS="${JAVA_OPTS} {{ tomcat_java_gc_opts }}"