Start WildFly as a systemd Service on Linux: Difference between revisions
No edit summary |
|||
Line 5: | Line 5: | ||
=Overview= | =Overview= | ||
We create a simple <tt>systemd</tt> <tt>Type=oneshot</tt> unit file that delegates the work of starting and stopping the instance to the System V wrappers shipped with EAP installation bundle. | We create a simple <tt>systemd</tt> <tt>Type=oneshot</tt> unit file that delegates the work of starting and stopping the instance to the System V wrappers shipped with EAP installation bundle. Note that [[em]] applies all this configuration automatically. | ||
=<tt>systemd</tt> File Locations= | =<tt>systemd</tt> File Locations= |
Revision as of 19:32, 16 February 2016
Internal
Overview
We create a simple systemd Type=oneshot unit file that delegates the work of starting and stopping the instance to the System V wrappers shipped with EAP installation bundle. Note that em applies all this configuration automatically.
systemd File Locations
We adapted the installation procedure after an ActiveMQ installation procedure that recommended placing files in /usr/lib/systemd/scripts and /usr/lib/systemd/system. However, a better location seems to be /etc/systemd/... More research is needed, the results will go here systemd Concepts#Unit_File_Location.
Install the Pre-Packaged System V Startup Scripts into Standard systemd Location
Copy the pre-packaged System V startup scripts (jboss-as-domain.sh, jboss-as-standalone.sh) from $JBOSS_HOME/bin/init.d into /usr/lib/systemd/scripts.
Perform the following operations as "root", re-name the scripts as indicated below.
For a standalone installation, name the script jboss.
cp $JBOSS_HOME/bin/init.d/jboss-as-standalone.sh /usr/lib/systemd/scripts/jboss
For a domain installation, name the script jboss-host-controller, regardless of whether we're configuring to start the domain controller or a subordinate host controller. This is because on the domain controller host, the domain controller process and the host controller process coincide.
cp $JBOSS_HOME/bin/init.d/jboss-as-domain.sh /usr/lib/systemd/scripts/jboss-host-controller
Customize the WildFly Startup Wrapper
Create the Unit File
Create the /usr/lib/systemd/system/jboss.service (or the /usr/lib/systemd/system/jboss-host-controller.service) unit file. Maintain the same nomenclature for consistency:
[Unit] Description=EAP Service After=network.target [Service] Type=oneshot ExecStart=/usr/lib/systemd/scripts/jboss-host-controller start ExecStop=/usr/lib/systemd/scripts/jboss-host-controller stop RemainAfterExit=yes Environment="JAVA_HOME=/opt/java" [Install] WantedBy=multi-user.target
Notify systemd of the existence of the new unit file
systemctl daemon-reload
Enable at Boot
systemctl enable jboss-host-controller.service