Jens Krämer

How to Control JBoss With systemd

 |  systemd, jboss, sysadmin, linux

Recently I set up JBoss on a fresh Debian install, and took the chance to introduce myself to systemd, the thing that is supposed to replace the good old SysV init system.

The JBoss download only came with an old style init script, so here’s the systemd service definition I came up with:

[Unit]
Description=Jboss Application Server
After=network.target

[Service]
Type=idle
Environment=JAVA_HOME=/opt/java JBOSS_HOME=/opt/jboss JAVA=/opt/java/bin/java JBOSS_LOG_DIR=/var/log/jboss "JAVA_OPTS=-Xms1024m -Xmx20480m -XX:MaxPermSize=768m"
User=jboss
Group=jboss
ExecStart=/opt/jboss/bin/standalone.sh
TimeoutStartSec=600
TimeoutStopSec=600

[Install]
WantedBy=multi-user.target

Simply place this into /etc/systemd/system/jboss-as-standalone.service and edit the Environment line to suit your installation paths / desired Java options. Then run systemctl daemon-reload to make systemd recognize the new file. You can now start/stop JBoss using systemctl {stop|start} jboss-as-standalone.service. To activate automatic startup on boot run systemctl enable jboss-as-standalone.service.

That’s it! If you ask me, the switch to systemd is a huge step into the right direction.