robertdebock / ansible-role-tomcat

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

tomcat and systemd 100% system usage #13

Closed pleutres closed 5 years ago

pleutres commented 5 years ago

Describe the bug When started using systemd service, the java process hang with 100% system CPU. When started with normal tomcat user, it started normally

To Reproduce Steps to reproduce the behavior:

  1. Run this role:
  2. Deploy a war with annotations, wait.

Expected behavior Normal startup with serviced

Error

Environment

Additional context Resolved with strace on java process, it was recursively reading : /proc/self/task/81569/cwd/proc/self/task/81569/cwd/proc/self/task/81569/cwd/proc/self/task/81569/cwd/proc/self/task/81569/cwd/proc/self/task/8156...

Java process was outside of his directory, even if launch with correct user.

Just add working_directory parameter to service.role:

` service_list:

robertdebock commented 5 years ago

Thanks @pleutres, I'll look into the issue a little later!

robertdebock commented 5 years ago

Hi, I can't reproduce the issue, I've used:

This virtual machine:

  config.vm.define "centos7-1" do |centos7|
    centos7.vm.box = "centos/7"
    centos7.vm.synced_folder '.', '/vagrant', disabled: true
  end

And this playbook:

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

  vars:
    tomcat_instances:
      - name: "tomcat-version9"
        version: 9

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

The machine is running, tomcat is started:

[vagrant@localhost ~]$ ps -ef | grep tomcat
tomcat    6059     1  0 19:16 ?        00:00:04 /usr/bin/java -Djava.util.logging.config.file=/opt/tomcat-version9/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-version9/bin/bootstrap.jar:/opt/tomcat-version9/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat-version9 -Dcatalina.home=/opt/tomcat-version9 -Djava.io.tmpdir=/opt/tomcat-version9/temp org.apache.catalina.startup.Bootstrap start

And the processes look good:

top - 19:25:44 up 12 min,  1 user,  load average: 0.00, 0.07, 0.10
Tasks:  83 total,   2 running,  81 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.3 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :   498812 total,     6468 free,   135328 used,   357016 buff/cache
KiB Swap:  2097148 total,  2096372 free,      776 used.   315196 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND      
 6059 tomcat    20   0 2093080  73512  14644 S  0.7 14.7   0:04.90 java         
    1 root      20   0  127984   6444   3916 S  0.0  1.3   0:02.12 systemd      
    2 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kthreadd     

Can you tell me how I can reproduce the issue?

robertdebock commented 5 years ago

I'm going to close the issue, if you have information how I can reproduce this (a playbook for example), please reopen and I will re-check.

pleutres commented 5 years ago

OK, the CentOS 7 VM has not be mount by me so I can not give more details for instance. If I can reproduce it in a VM mount by me I'll keep you update.