Start WildFly as a systemd Service on Linux: Difference between revisions
No edit summary |
|||
(24 intermediate revisions by the same user not shown) | |||
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= | |||
Place the newly created unit file in /usr/lib/systemd/system and the companion scripts in /usr/lib/systemd/scripts. For more details, see [[systemd Concepts#Unit_File_Location|systemd Unit File Location]]. | |||
=Install the Pre-Packaged System V Startup Scripts into Standard <tt>systemd</tt> Location= | |||
Copy the pre-packaged System V startup scripts (<tt>jboss-as-domain.sh</tt>, <tt>jboss-as-standalone.sh</tt> for EAP 6, <tt>jboss-eap-rhel.sh</tt> for EAP 7) from <tt>$JBOSS_HOME/bin/init.d</tt> into <tt>/usr/lib/systemd/scripts</tt>. | |||
Perform the following operations as "root", re-name the scripts as indicated below. | |||
For a standalone installation, name the script <tt>jboss</tt>. | |||
<pre> | |||
cp $JBOSS_HOME/bin/init.d/jboss-as-standalone.sh /usr/lib/systemd/scripts/jboss | |||
</pre> | |||
For a domain installation, name the script <tt>jboss-host-controller</tt>, 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. | |||
<pre> | |||
cp $JBOSS_HOME/bin/init.d/jboss-as-domain.sh /usr/lib/systemd/scripts/jboss-host-controller | |||
</pre> | |||
=Customize the WildFly Startup Wrapper= | |||
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;"> | |||
:[[Customize WildFly Startup Wrapper]] | |||
</blockquote> | |||
=Create the Unit File= | |||
Create the <tt>/usr/lib/systemd/system/jboss.service</tt> (or the <tt>/usr/lib/systemd/system/jboss-host-controller.service</tt>) unit file. Maintain the same nomenclature for consistency: | |||
{{Warn|Modify the environment variables JAVA_HOME, JBOSS_HOME , etc. to match your system's values.}} | |||
<pre> | |||
[Unit] | |||
Description=EAP Service | |||
After=syslog.target network-online.target | |||
Before=httpd.service | |||
[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" | |||
Environment="JBOSS_HOME=/opt/jboss" | |||
Environment="JBOSS_USER=eap" | |||
Environment="JBOSS_MODE=domain" | |||
[Install] | |||
WantedBy=multi-user.target | |||
</pre> | |||
==After and Before== | |||
The name of the target used in "After" and "Before" declarations may vary from system to system. For example, "network.taget" on some system may be "network-online.target" on other systems. You can query the targets with [[systemctl#list-units|systemctl list-units]]. | |||
=Notify <tt>systemd</tt> of the existence of the new unit file= | |||
<pre> | |||
systemctl daemon-reload | |||
</pre> | |||
=Enable at Boot= | |||
<pre> | |||
systemctl enable jboss-host-controller.service | |||
</pre> | |||
=The Line that Starts The Process= | |||
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;"> | |||
:[[WildFly - The Wrapper Script Line that Starts the Process]] | |||
</blockquote> |
Latest revision as of 17:08, 28 June 2017
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
Place the newly created unit file in /usr/lib/systemd/system and the companion scripts in /usr/lib/systemd/scripts. For more details, see systemd 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 for EAP 6, jboss-eap-rhel.sh for EAP 7) 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:
Modify the environment variables JAVA_HOME, JBOSS_HOME , etc. to match your system's values.
[Unit] Description=EAP Service After=syslog.target network-online.target Before=httpd.service [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" Environment="JBOSS_HOME=/opt/jboss" Environment="JBOSS_USER=eap" Environment="JBOSS_MODE=domain" [Install] WantedBy=multi-user.target
After and Before
The name of the target used in "After" and "Before" declarations may vary from system to system. For example, "network.taget" on some system may be "network-online.target" on other systems. You can query the targets with systemctl list-units.
Notify systemd of the existence of the new unit file
systemctl daemon-reload
Enable at Boot
systemctl enable jboss-host-controller.service