diff --git a/defaults/main.yml b/defaults/main.yml index 38e8c64..a9fb064 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -94,6 +94,8 @@ tomcat_m_jmx_port: 8186 tomcat_m_jmx_disable_additional_ports: True tomcat_m_jmx_localhost_only: False tomcat_m_jmx_ip_address: '{{ ansible_default_ipv4.address }}' +tomcat_m_jpda_port: 5005 +tomcat_m_jpda_opts: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address={{ tomcat_m_jpda_port }}" # tomcat_m_jmx_auth_dir: '{{ tomcat_m_instances_base_path }}' # tomcat_m_jmx_monitorpass: define_in_a_vault_file diff --git a/tasks/main.yml b/tasks/main.yml index 89e5022..9f3b2b7 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -299,6 +299,18 @@ notify: tomcat multiple-instances restart tags: ['tomcat', 'tomcat_instances', 'tomcat_init'] +- name: Install the debug conf used by the systemd unit + ansible.builtin.template: + src: tomcat-debug.conf.j2 + dest: "/etc/systemd/system/tomcat-instance-{{ item.http_port }}.service.d/debug.conf.disabled" + mode: "0644" + owner: root + group: root + loop: '{{ tomcat_m_instances }}' + when: tomcat_use_systemd_unit + notify: tomcat multiple-instances restart + tags: ['tomcat', 'tomcat_instances', 'tomcat_init'] + - name: Install the tomcat instances default file ansible.builtin.template: src: tomcat-default.j2 diff --git a/templates/tomcat-debug.conf.j2 b/templates/tomcat-debug.conf.j2 new file mode 100644 index 0000000..af91b6f --- /dev/null +++ b/templates/tomcat-debug.conf.j2 @@ -0,0 +1,3 @@ +[Service] +Environment="{{ tomcat_m_jpda_opts }}" +Environment="JPDAEXEC=jpda" \ No newline at end of file diff --git a/templates/tomcat-start.sh.j2 b/templates/tomcat-start.sh.j2 index 99bbf0f..70f9e05 100644 --- a/templates/tomcat-start.sh.j2 +++ b/templates/tomcat-start.sh.j2 @@ -15,6 +15,7 @@ set -e [ -n "$JSP_COMPILER" ] && JAVA_OPTS="$JAVA_OPTS -Dbuild.compiler=\"$JSP_COMPILER\"" export JAVA_OPTS +export JPDA_OPTS # Enable the Java security manager? SECURITY="" @@ -22,4 +23,9 @@ SECURITY="" # Start Tomcat -cd $CATALINA_BASE && exec $CATALINA_HOME/bin/catalina.sh run $SECURITY +if [ -n $JPDAEXEC ]; then + echo "Starting Tomcat with JPDA debugger support" + echo "JPDA_OPTS: \"$JPDA_OPTS\"" +fi + +cd $CATALINA_BASE && exec $CATALINA_HOME/bin/catalina.sh $JPDAEXEC run $SECURITY