robertdebock / ansible-role-tomcat

Install and configure tomcat on your system.
https://robertdebock.nl/
Apache License 2.0
46 stars 57 forks source link

Xmx configuration #14

Closed pleutres closed 5 years ago

pleutres commented 5 years ago

Describe the bug Xmx parameter use

To Reproduce Steps to reproduce the behavior:

  1. Run this role: ansible-role-tomcat
  2. with XMX 6G

Expected behavior Tomcat started with -Xmx6G parameter

Error Tomcat is not started

Environment

Additional context I did not see the use of "xmx" attribute of tomcat instance in the role.

robertdebock commented 5 years ago

I'll try to reproduce, thanks for the notification.

robertdebock commented 5 years ago

I can't reproduce, so let me try to explain what I did:

Setup the machine using Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.define "centos7-1" do |centos7|
    centos7.vm.box = "centos/7"
    centos7.vm.synced_folder '.', '/vagrant', disabled: true
    centos7.vm.provider :libvirt do |domain|
      domain.memory = 8192
    end
  end
end

Run this playbook.yml against the machine:

---
- name: Converge
  hosts: all
  gather_facts: no
  become: yes

  vars:
    tomcat_xmx: 6G
    tomcat_instances:
      - name: "tomcat-default"

  roles:
    - robertdebock.bootstrap
    - robertdebock.java
    - robertdebock.tomcat

First time there are (many) changes:

robertdebock.bootstrap : install software with yum  centos7-1   raw 0:00:03 0:00:12 CHANGED
robertdebock.bootstrap : install software to support preview modules    centos7-1   package 0:00:17 0:00:08 CHANGED
robertdebock.java : install openjdk java (package)  centos7-1   package 0:00:26 0:00:19 CHANGED
robertdebock.tomcat : ensure instance group exists  centos7-1   group   0:00:47 0:00:00 CHANGED
robertdebock.tomcat : ensure instance user exists   centos7-1   user    0:00:48 0:00:00 CHANGED
robertdebock.tomcat : ensure instance directory exists  centos7-1   file    0:00:48 0:00:00 CHANGED
robertdebock.tomcat : download tomcat source    centos7-1   get_url 0:00:49 0:00:01 CHANGED
robertdebock.tomcat : install tomcat instance   centos7-1   unarchive   0:00:50 0:00:01 CHANGED
robertdebock.tomcat : configure tomcat instance - server.xml    centos7-1   template    0:00:52 0:00:00 CHANGED
robertdebock.service : install required packages    centos7-1   package 0:00:53 0:00:01 CHANGED
robertdebock.service : configure systemd service    centos7-1   template    0:00:55 0:00:00 CHANGED
robertdebock.tomcat : restart tomcat instance   centos7-1   service 0:00:56 0:00:00 CHANGED
robertdebock.tomcat : start and enable tomcat instance  centos7-1   service 0:00:57 0:00:02 CHANGED

Second run, nothing is changed, so tomcat is running. Verified using ps -ef:

tomcat    6301     1  0 08:11 ?        00:00:07 /usr/bin/java -Djava.util.logging.config.file=/opt/tomcat-default/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /opt/tomcat-default/bin/bootstrap.jar:/opt/tomcat-default/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat-default -Dcatalina.home=/opt/tomcat-default -Djava.io.tmpdir=/opt/tomcat-default/temp org.apache.catalina.startup.Bootstrap start

Please let me know what you experience.

pleutres commented 5 years ago

On the ps -ef command I do not see any Xmx parameter. I expect to see a -Xmx6g parameter somewhere on this line ?

robertdebock commented 5 years ago

Okay, I'll look into it, thanks for your feedback.

robertdebock commented 5 years ago

You are correct, some time ago this role started using a service dependency and this configuration was lost.

I'll work on a fix, bit embarrassed, but thanks for the feedback!

robertdebock commented 5 years ago

The fix was tested and released.

Thanks for pointing out this silly mistake.