How to Control JBoss With systemd
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.
Comments
Camusensei
Works perfectly. (I configured JAVA_OPTS in standalone.conf so I removed them from this script)
Thank you very much!!!
Tom
You might want to include a "ExecStop" command to shutdown (yes, sometimes they want to shutdown Jboss on purpose ;-) ) the server?
Root
Thanks its working , i was struggled with this many times now its working thank you very much.