From d0434a575622bb092c1cedbc80df314c0a00817e Mon Sep 17 00:00:00 2001 From: Anton Melekhin <44847512+antmelekhin@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:17:52 +0400 Subject: [PATCH] feat: add variables to `setenv.sh` to make it possible to change JVM arguments (#9) --- README.md | 5 +++++ defaults/main.yml | 6 ++++++ templates/setenv.sh.j2 | 27 +++++++++++++-------------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ee50222..51af4cd 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,12 @@ Role Variables - `jira_username` and `jira_group` Unix username and group (default: `jira`). - `jira_root_path` Path to Jira installation directory (default: `/opt/atlassian/jira`). - `jira_home_path` Path to Jira home directory (default: `/var/atlassian/application-data/jira`). +- `jira_min_nofiles_limit` If the limit of files that Jira can open is too low, it will be set to this value (default: `16384`). +- `jira_jvm_support_recommends_args` Occasionally Atlassian Support may recommend that you set some specific JVM arguments (default: `null`). +- `jira_jvm_gc_args` You can use variable below to modify garbage collector settings (default: `-XX:+ExplicitGCInvokesConcurrent`). - `jira_jvm_minimum_memory` and `jira_jvm_maximum_memory` The minimum and maximum size of the heap (default: `384m` and `2048m`). +- `jira_jvm_initial_code_cache_size` and `jira_jvm_reserved_code_cache_size` The size of JVM code cache (default: `32m` and `512m`). A high value of reserved size allows Jira to work with more installed apps. +- `jira_jvm_required_args` The following are the required arguments for Jira. - `jira_db_configuration` DB connection configuration (default: `false`). - `jira_db_address` IP address or DNS name of DB server. - `jira_db_port` DB port. diff --git a/defaults/main.yml b/defaults/main.yml index c20eb1d..42768a8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -13,8 +13,14 @@ jira_root_path: '/opt/atlassian/jira' jira_home_path: '/var/atlassian/application-data/jira' # Jira environment configuration. +jira_min_nofiles_limit: 16384 +jira_jvm_support_recommends_args: '' +jira_jvm_gc_args: '-XX:+ExplicitGCInvokesConcurrent' jira_jvm_minimum_memory: '384m' jira_jvm_maximum_memory: '2048m' +jira_jvm_initial_code_cache_size: '32m' +jira_jvm_reserved_code_cache_size: '512m' +jira_jvm_required_args: '-Djava.awt.headless=true -Datlassian.standalone=JIRA -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dmail.mime.decodeparameters=true -Dorg.dom4j.factory=com.atlassian.core.xml.InterningDocumentFactory' # Jira database connection settings. jira_db_configuration: false diff --git a/templates/setenv.sh.j2 b/templates/setenv.sh.j2 index 2fdf4b4..da77b37 100644 --- a/templates/setenv.sh.j2 +++ b/templates/setenv.sh.j2 @@ -1,42 +1,41 @@ {{ ansible_managed | comment }} -# # If the limit of files that Jira can open is too low, it will be set to this value. # -MIN_NOFILES_LIMIT=16384 +MIN_NOFILES_LIMIT={{ jira_min_nofiles_limit }} # # One way to set the JIRA HOME path is here via this variable. Simply uncomment it and set a valid path like /jira/home. You can of course set it outside in the command terminal. That will also work. # -JIRA_HOME="{{ jira_home_path }}" +JIRA_HOME='{{ jira_home_path }}' # # Occasionally Atlassian Support may recommend that you set some specific JVM arguments. You can use this variable below to do that. # -JVM_SUPPORT_RECOMMENDED_ARGS="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8" +JVM_SUPPORT_RECOMMENDED_ARGS='{{ jira_jvm_support_recommends_args }}' # -# You can use variable below to modify garbage collector settings. -# For Java 8 we recommend default settings -# For Java 11 and relatively small heaps we recommend: -XX:+UseParallelGC -# For Java 11 and larger heaps we recommend: -XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent +# You can use variable below to modify garbage collector settings. +# For Java 8 we recommend default settings +# For Java 11 and relatively small heaps we recommend: -XX:+UseParallelGC +# For Java 11 and larger heaps we recommend: -XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent # -JVM_GC_ARGS="-XX:+ExplicitGCInvokesConcurrent" +JVM_GC_ARGS='{{ jira_jvm_gc_args }}' # # The following 2 settings control the minimum and maximum given to the JIRA Java virtual machine. In larger JIRA instances, the maximum amount will need to be increased. # -JVM_MINIMUM_MEMORY="{{ jira_jvm_minimum_memory }}" -JVM_MAXIMUM_MEMORY="{{ jira_jvm_maximum_memory }}" +JVM_MINIMUM_MEMORY='{{ jira_jvm_minimum_memory }}' +JVM_MAXIMUM_MEMORY='{{ jira_jvm_maximum_memory }}' # # The following setting configures the size of JVM code cache. A high value of reserved size allows Jira to work with more installed apps. # -JVM_CODE_CACHE_ARGS='-XX:InitialCodeCacheSize=32m -XX:ReservedCodeCacheSize=512m' +JVM_CODE_CACHE_ARGS='-XX:InitialCodeCacheSize={{ jira_jvm_initial_code_cache_size }} -XX:ReservedCodeCacheSize={{ jira_jvm_reserved_code_cache_size }}' # # The following are the required arguments for Jira. # -JVM_REQUIRED_ARGS='-Djava.awt.headless=true -Datlassian.standalone=JIRA -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dmail.mime.decodeparameters=true -Dorg.dom4j.factory=com.atlassian.core.xml.InterningDocumentFactory' +JVM_REQUIRED_ARGS='{{ jira_jvm_required_args }}' # Uncomment this setting if you want to import data without notifications # @@ -53,7 +52,7 @@ JVM_REQUIRED_ARGS='-Djava.awt.headless=true -Datlassian.standalone=JIRA -Dorg.ap # Prevents the JVM from suppressing stack traces if a given type of exception # occurs frequently, which could make it harder for support to diagnose a problem. #----------------------------------------------------------------------------------- -JVM_EXTRA_ARGS="-XX:-OmitStackTraceInFastThrow -Djava.locale.providers=COMPAT" +JVM_EXTRA_ARGS='-XX:-OmitStackTraceInFastThrow -Djava.locale.providers=COMPAT' CURRENT_NOFILES_LIMIT=$( ulimit -Hn ) ulimit -Sn $CURRENT_NOFILES_LIMIT