wildfly as systemd service

15,623

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

Share:
15,623
Mehrdad Islamkhah
Author by

Mehrdad Islamkhah

Updated on June 18, 2022

Comments

  • Mehrdad Islamkhah
    Mehrdad Islamkhah almost 2 years

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

    • Mark Stosberg
      Mark Stosberg about 7 years
      Include the systemd .service file you are having a problem with in your question
    • Mehrdad Islamkhah
      Mehrdad Islamkhah about 7 years
      what do you mean ? what should i add in where ?
    • Mark Stosberg
      Mark Stosberg about 7 years
      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.
    • Mehrdad Islamkhah
      Mehrdad Islamkhah about 7 years
      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 ?
    • Will T
      Will T about 7 years
      You are using a 64bit JDK aren't you ?
    • Mehrdad Islamkhah
      Mehrdad Islamkhah about 7 years
      /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64‌​/jre/
    • Mehrdad Islamkhah
      Mehrdad Islamkhah about 7 years
      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
  • P Marecki
    P Marecki about 7 years
    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: unix.stackexchange.com/questions/126009/…
  • Oleg Gritsak
    Oleg Gritsak about 7 years
    For network servers it shouldn't matter, but I guess, it will not harm anyway. So, edited my post, thanks.