wildfly as systemd service

Mehrdad Islamkhah picture Mehrdad Islamkhah · Mar 20, 2017 · Viewed 13.1k times · Source

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 ....

Answer

Oleg Gritsak picture Oleg Gritsak · Mar 21, 2017

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