Chapter 7. Running and removing JBoss EAP as a service on RHEL
7.1. JBoss EAP as a service on RHEL Copy linkLink copied to clipboard!
When using the archive, JBoss EAP installation manager, and GUI installation methods, you can configure JBoss EAP to run as a service in Red Hat Enterprise Linux RHEL. This enables the JBoss EAP service to start automatically when the RHEL server starts.
A server installed using RPM is already configured to run as a service.
You can use one of two daemon services:
- Systemd (System daemon). Systemd scripts are supplied with a basic configuration, and are intended to be used for standalone and domain mode instances.
-
Init, also known as "System V init", or
SysVinit
. Init scripts are deprecated in favor of Systemd scripts.
7.2. Running JBoss EAP as a Systemd service on RHEL Copy linkLink copied to clipboard!
You can configure JBoss EAP to run as a Systemd service in Red Hat Enterprise Linux RHEL. This enables the JBoss EAP service to start automatically when the RHEL server starts. You must generate a systemd unit file with the username:groupname
to launch the server.
Prerequisites
- You have downloaded and Installed JBoss EAP.
-
You have set the
JAVA_HOME
system environment variable. - You have administrator access to the RHEL server.
Procedure
Create the user and group that will be used to launch the server:
sudo groupadd -r groupname sudo useradd -r -g groupname -d $EAP_HOME -s /sbin/nologin username sudo chown -R username:groupname $EAP_HOME
$ sudo groupadd -r groupname $ sudo useradd -r -g groupname -d $EAP_HOME -s /sbin/nologin username $ sudo chown -R username:groupname $EAP_HOME
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe commands in this procedure require root privileges to run. Either run
su
- to switch to the root user or preface the commands withsudo
.Generate the systemd unit file:
Standalone mode
sudo cd $EAP_HOME/bin/systemd sudo ./generate_systemd_unit.sh standalone username groupname
$ sudo cd $EAP_HOME/bin/systemd $ sudo ./generate_systemd_unit.sh standalone username groupname
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Domain mode
sudo cd $EAP_HOME/bin/systemd sudo ./generate_systemd_unit.sh domain username groupname
$ sudo cd $EAP_HOME/bin/systemd $ sudo ./generate_systemd_unit.sh domain username groupname
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the start-up options in the
jboss-eap-standalone.conf
orjboss-eap-domain.conf
by using a text editor and set the options for your JBoss EAP installation:Standalone mode
sudo vim $EAP_HOME/bin/systemd/jboss-eap-standalone.conf
$ sudo vim $EAP_HOME/bin/systemd/jboss-eap-standalone.conf
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Domain mode
sudo vim $EAP_HOME/bin/systemd/jboss-eap-domain.conf
$ sudo vim $EAP_HOME/bin/systemd/jboss-eap-domain.conf
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the systemd unit file and the server configuration file, and reload the service daemon:
Standalone mode
sudo cp $EAP_HOME/bin/systemd/jboss-eap-standalone.service $(pkg-config systemd --variable=systemd_system_unit_dir) sudo cp $EAP_HOME/bin/systemd/jboss-eap-standalone.conf /etc/sysconfig/ sudo systemctl daemon-reload
$ sudo cp $EAP_HOME/bin/systemd/jboss-eap-standalone.service $(pkg-config systemd --variable=systemd_system_unit_dir) $ sudo cp $EAP_HOME/bin/systemd/jboss-eap-standalone.conf /etc/sysconfig/ $ sudo systemctl daemon-reload
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Domain mode
sudo cp $EAP_HOME/bin/systemd/jboss-eap-domain.service $(pkg-config systemd --variable=systemd_system_unit_dir) sudo cp $EAP_HOME/bin/systemd/jboss-eap-domain.conf /etc/sysconfig/ sudo systemctl daemon-reload
$ sudo cp $EAP_HOME/bin/systemd/jboss-eap-domain.service $(pkg-config systemd --variable=systemd_system_unit_dir) $ sudo cp $EAP_HOME/bin/systemd/jboss-eap-domain.conf /etc/sysconfig/ $ sudo systemctl daemon-reload
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enable the service:
Standalone mode
sudo systemctl enable jboss-eap-standalone.service sudo systemctl start jboss-eap-standalone.service
$ sudo systemctl enable jboss-eap-standalone.service $ sudo systemctl start jboss-eap-standalone.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Domain mode
sudo systemctl enable jboss-eap-domain.service sudo systemctl start jboss-eap-domain.service
$ sudo systemctl enable jboss-eap-domain.service $ sudo systemctl start jboss-eap-domain.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources
- For more information about controlling the state of services, see Management system services in the RHEL Configuring basic system settings guide.
- For more information about viewing error logs, see Bootup logging in the JBoss EAP Configuration Guide.
7.3. Removing JBoss EAP Systemd service on RHEL Copy linkLink copied to clipboard!
You can remove the Systemd services associated with your server instance. The next steps describe how to do it.
Prerequisites
- You have JBoss EAP installed as a Systemd service.
Procedure
When the service is running, open a terminal and stop the service with one of the following commands:
Standalone mode
sudo systemctl stop jboss-eap-standalone.service
$ sudo systemctl stop jboss-eap-standalone.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Domain mode
sudo systemctl stop jboss-eap-domain.service
$ sudo systemctl stop jboss-eap-domain.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe commands in this procedure require root privileges to run. Either run
su
- to switch to the root user or preface the commands withsudo
.Disable the service:
Standalone mode
sudo systemctl disable jboss-eap-standalone.service
$ sudo systemctl disable jboss-eap-standalone.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Domain mode
sudo systemctl disable jboss-eap-domain.service
$ sudo systemctl disable jboss-eap-domain.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the configuration file and startup script:
Standalone mode
sudo rm "$(pkg-config systemd --variable=systemd_system_unit_dir)/jboss-eap-standalone.service" sudo rm "/etc/sysconfig/jboss-eap-standalone.conf" sudo systemctl daemon-reload
$ sudo rm "$(pkg-config systemd --variable=systemd_system_unit_dir)/jboss-eap-standalone.service" $ sudo rm "/etc/sysconfig/jboss-eap-standalone.conf" $ sudo systemctl daemon-reload
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Domain mode
sudo rm "$(pkg-config systemd --variable=systemd_system_unit_dir)/jboss-eap-domain.service" sudo rm "/etc/sysconfig/jboss-eap-domain.conf" sudo systemctl daemon-reload
$ sudo rm "$(pkg-config systemd --variable=systemd_system_unit_dir)/jboss-eap-domain.service" $ sudo rm "/etc/sysconfig/jboss-eap-domain.conf" $ sudo systemctl daemon-reload
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.4. Running JBoss EAP as an Init service on RHEL Copy linkLink copied to clipboard!
Init scripts are deprecated in favor of Systemd scripts. Additional packages may need to be installed to provide this functionality. For example, when using RHEL 9, you must install the initscripts
package to use Init services.
You can configure JBoss EAP to run as a service in Red Hat Enterprise Linux RHEL. This enables the JBoss EAP service to start automatically when the RHEL server starts.
Prerequisites
- You have downloaded and Installed JBoss EAP.
-
You have set the
JAVA_HOME
system environment variable. - You have administrator access to the RHEL server.
-
When using RHEL, you have the
initscripts
package installed.
Procedure
-
Configure the start-up options in the
jboss-eap.conf
file by opening thejboss-eap.conf
in a text editor and set the options for your JBoss EAP installation. Copy the service initialization and configuration files into the system directories:
Copy the modified service configuration file to the
/etc/default
directory.NoteThe commands in this procedure require root privileges to run. Either run
su
- to switch to the root user or preface the commands withsudo
.sudo cp EAP_HOME/bin/init.d/jboss-eap.conf /etc/default
$ sudo cp EAP_HOME/bin/init.d/jboss-eap.conf /etc/default
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the service startup script to the
/etc/init.d
directory and give it execute permissions:sudo cp EAP_HOME/bin/init.d/jboss-eap-rhel.sh /etc/init.d sudo chmod +x /etc/init.d/jboss-eap-rhel.sh sudo restorecon /etc/init.d/jboss-eap-rhel.sh
$ sudo cp EAP_HOME/bin/init.d/jboss-eap-rhel.sh /etc/init.d $ sudo chmod +x /etc/init.d/jboss-eap-rhel.sh $ sudo restorecon /etc/init.d/jboss-eap-rhel.sh
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Add the new
jboss-eap-rhel.sh
service to the list of automatically started services using thechkconfig
service management command:sudo chkconfig --add jboss-eap-rhel.sh
$ sudo chkconfig --add jboss-eap-rhel.sh
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the service has been installed correctly by using the following command:
sudo systemctl start jboss-eap-rhel
$ sudo systemctl start jboss-eap-rhel
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: To make the service start automatically when the RHEL server starts, run the following command:
sudo chkconfig jboss-eap-rhel.sh on
$ sudo chkconfig jboss-eap-rhel.sh on
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
-
To check the permissions of a file, enter the
ls -l
command in the directory containing the file. To check that the automatic service start is enabled, enter the following command:
sudo chkconfig --list jboss-eap-rhel.sh
$ sudo chkconfig --list jboss-eap-rhel.sh
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources
- For more information about controlling the state of services, see Management system services in the RHEL Configuring basic system settings guide.
- For more information about viewing error logs, see Bootup logging in the RHEL Configuration Guide.
7.5. Removing JBoss EAP Init service on RHEL Copy linkLink copied to clipboard!
You can remove the Systemd services associated with your server instance. The next steps describe how to do it.
Prerequisites
- You have JBoss EAP installed as an Init service.
Procedure
When the service is running, open a terminal and stop the service with one of the following command:
sudo service jboss-eap-rhel.sh stop
$ sudo service jboss-eap-rhel.sh stop
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe commands in this procedure require root privileges to run. Either run
su
- to switch to the root user or preface the commands withsudo
.Remove JBoss EAP from the list of services:
sudo chkconfig --del jboss-eap-rhel.sh
$ sudo chkconfig --del jboss-eap-rhel.sh
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the configuration file and startup script:
sudo rm /etc/init.d/jboss-eap-rhel.sh sudo rm /etc/default/jboss-eap.conf
$ sudo rm /etc/init.d/jboss-eap-rhel.sh $ sudo rm /etc/default/jboss-eap.conf
Copy to Clipboard Copied! Toggle word wrap Toggle overflow