6

I wanna make wildfly-domain as a systemd service in centos7 in works by root user but when i start it as wilfly user after a while it shows error:

java.lang.OutOfMemoryError: unable to create new native threadESC

and stop . even stop service doesn't work .

I tried to change heap-memo and ... but the user is a problem! How can I solve this?

service file is ib wildfly8/bin/init.d/wildfly-init-redhat.sh I tried "ulimit -n " at the top of service script but nothing changed! I have 256Gb Ram and 64core CPU but ....

Community
  • 1
  • 1
  • Include the `systemd` `.service` file you are having a problem with in your question – Mark Stosberg Mar 20 '17 at 16:44
  • what do you mean ? what should i add in where ? – Mehrdad Islamkhah Mar 20 '17 at 16:47
  • 1
    You said you are using `systemd` service. So, there should be a file with the extension `.service` in `/etc/systemd/system/`. If you aren't using a `.service` file, you aren't using `systemd`. If you are *are*, paste the contents of that `.service` file into your question. – Mark Stosberg Mar 20 '17 at 17:46
  • i did it in /etc/init.d/ but i changed it into systemd .now i have a systemd wilfly service . when i run it by root user , no problem but when i start it with wilfly user i works , but after 5 minutes it fall down as i said , how can i change wilfly user limitations ? – Mehrdad Islamkhah Mar 20 '17 at 18:32
  • You are using a 64bit JDK aren't you ? – Will Tatam Mar 20 '17 at 22:59
  • /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/ – Mehrdad Islamkhah Mar 20 '17 at 23:26
  • i use openJDK 1.5.0.121 . i told you if run domain.sh with root user every things are ok . but wildfly user after a while shutdown the application – Mehrdad Islamkhah Mar 20 '17 at 23:27

1 Answers1

14

Right place for unit is:

/etc/systemd/system/wildfly.service

This minimal is ok

[Unit]
Description=WildFly application server
Wants=network-online.target 
After=network-online.target

[Service]
Type=simple
User=web
Group=web
ExecStart=/opt/wildfly-10.1.0.Final/bin/domain.sh
Restart=always
RestartSec=20

[Install]
WantedBy=multi-user.target

You should edit only ExecStart field to match your path.

Create user web with

useradd web

Also exec by root:

chown -R web:web /opt/wildfly-10.1.0.Final/

When

systemctl start wildfly
systemctl enable wildfly

If you get OOMs, inspect your limits

[Service] section of systemd unit, like

LimitFSIZE=infinity
LimitCPU=infinity
LimitAS=infinity
LimitNOFILE=64000
LimitNPROC=64000

or /etc/security/limits.d/ /etc/security/limits.conf

Oleg Gritsak
  • 548
  • 7
  • 26
  • 2
    `network.target` might be too early (had problem with that on fast machine with RHEL7); use `Wants=network-online.target After=network-online.target` so that the interfaces are properly configured on OS side; taken from here: https://unix.stackexchange.com/questions/126009/cause-a-script-to-execute-after-networking-has-started/126146#126146 – P Marecki Apr 02 '17 at 13:40
  • For network servers it shouldn't matter, but I guess, it will not harm anyway. So, edited my post, thanks. – Oleg Gritsak Apr 05 '17 at 02:18