Chapter 4. Configuring JBoss EAP to Run as a Service
4.1. Configuring JBoss EAP as a Service in Red Hat Enterprise Linux (ZIP and Installer Installations)
Prerequisites
Configuring JBoss EAP as a Service in Red Hat Enterprise Linux
Customize the start-up options in the
jboss-eap.conf
file.The startup script and an associated configuration file are located in the
EAP_HOME/bin/init.d/
directory. Openjboss-eap.conf
in a text editor and set the options for your JBoss EAP installation.There are several options in
jboss-eap.conf
file, but at the minimum you must provide the correct values forJBOSS_HOME
and theJBOSS_USER
.You can customize the other options provided in the configuration file by uncommenting and editing the respective lines. If you do not, the service will default to starting a standalone JBoss EAP server using the default configuration file,
standalone.xml
.NoteIf you want the service to start JBoss EAP as a managed domain, add
JBOSS_MODE=domain
tojboss-eap.conf
.To specify custom domain configuration files, add
JBOSS_DOMAIN_CONFIG=DOMAIN_CONFIG_FILE.xml
andJBOSS_HOST_CONFIG=HOST_CONFIG_FILE.xml
. By default, JBoss EAP usesdomain.xml
andhost.xml
as the domain configuration files.Copy the service files into the system directories.
Copy the modified service configuration file to the
/etc/default
directory.$ sudo cp EAP_HOME/bin/init.d/jboss-eap.conf /etc/default
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
Add the new
jboss-eap-rhel.sh
service to list of automatically started services using thechkconfig
service management command:$ sudo chkconfig --add jboss-eap-rhel.sh
Test that the service has been installed correctly by using one of the following commands.
For Red Hat Enterprise Linux 6:
$ sudo service jboss-eap-rhel.sh start
For Red Hat Enterprise Linux 7 and later:
$ sudo service jboss-eap-rhel start
The service will start. If you get an error, check the error logs and make sure that the options in the configuration file are set correctly.
To make the service start automatically when the Red Hat Enterprise Linux server starts, run the following command:
$ sudo chkconfig jboss-eap-rhel.sh on
If you want to remove the JBoss EAP service, use the following procedure.
Removing the JBoss EAP Service in Red Hat Enterprise Linux
If the service is running, open a terminal and stop the service with one of the following commands.
For Red Hat Enterprise Linux 6:
$ sudo service jboss-eap-rhel.sh stop
For Red Hat Enterprise Linux 7 and later:
$ sudo service jboss-eap-rhel stop
Remove JBoss EAP from the list of services:
$ sudo chkconfig --del jboss-eap-rhel.sh
Delete the service configuration file and startup script:
$ sudo rm /etc/init.d/jboss-eap-rhel.sh $ sudo rm /etc/default/jboss-eap.conf
4.2. Configuring JBoss EAP as a Service in Red Hat Enterprise Linux (RPM Installation)
Prerequisites
- Install JBoss EAP as an RPM installation.
- Administrator privileges on the server.
It is not supported to configure more than one JBoss EAP instance as a system service on a single machine.
An RPM installation of JBoss EAP installs everything that is required to run JBoss EAP as a service. Use one of the following commands to activate the JBoss EAP service to start automatically at system boot.
For the commands below, replace EAP_SERVICE_NAME
with either eap7-standalone
for a standalone JBoss EAP server, or eap7-domain
for a managed domain.
For Red Hat Enterprise Linux 6:
chkconfig EAP_SERVICE_NAME on
For Red Hat Enterprise Linux 7 and later:
systemctl enable EAP_SERVICE_NAME.service
To start or stop an RPM installation of JBoss EAP on demand, see the RPM instructions in the JBoss EAP Configuration Guide.
See the RPM service configuration files appendix in the JBoss EAP Configuration Guide for further details and options.
4.3. Configuring JBoss EAP as a Service in Microsoft Windows Server
Prerequisites
Using the set
command to set system environment variables in a Windows Server command prompt will not permanently set the environment variable. You must use either the setx
command, or the System interface in the Control Panel.
Configuring JBoss EAP as a Service in Microsoft Windows Server
Create two system environment variables:
-
JBOSS_HOME
pointing to the JBoss EAP installation directory. -
NOPAUSE=1
-
Install the JBoss Core Services Jsvc Package
If not already configured, download and extract the JBoss Core Services Jsvc package.
- Open a browser and log in to the Red Hat Customer Portal JBoss Software Downloads page.
- Select Apache Jsvc in the Product drop-down menu.
- Select the latest version from the Version drop-down menu.
- Find Red Hat JBoss Core Services Apache Jsvc in the list, ensuring that you select the correct platform and architecture for your system, and click the Download link.
Extract the downloaded ZIP file into the directory containing your JBoss EAP installation directory.
This will result in a
jbcs-jsvc-<VERSION>
directory at the same depth as your JBoss EAP installation directory. For example:C:\Program Files ├── jboss-eap-7.3 │ ├── bin │ └── ... └── jbcs-jsvc-<VERSION>
Install the Service
Open a terminal, and change directories to
EAP_HOME\bin
.Below are examples of a basic
service.bat install
command to create a new service for either a standalone server, or a server in a managed domain. For a list of all possible options, runservice.bat
without any arguments.ImportantIf you specify the
/jbossuser
and/jbosspass
parameters, you must ensure that your JBoss EAP user’s password does not contain a hash (#
) or a semicolon (;
).Execute the following command, adjusting the log level for the service as required:
For a standalone server:
service.bat install /loglevel INFO
For a server in a managed domain:
Use the
/host
parameter to specify the name of the JBoss EAP host controller being controlled by the service. You can see valid values for the name by executingls /host
in the management CLI.Replace
EAP_HOST_NAME
in the command below with your JBoss EAP host controller name. If you specify the/host
parameter without providing a JBoss EAP host controller name, the name defaults tomaster
.service.bat install /host EAP_HOST_NAME /loglevel INFO
A new Windows service will be created with name
JBossEAP7
.Verify the New Service in the
Services
consoleOpen the Windows Services console (
services.msc
) and verify that the service was created.If the default service name was used, in the list of Windows services the new service will have the display name:
JBossEAP7
. From the Services console you can start and stop the service, as well change its settings of how and when it starts.Starting and Stopping the JBoss EAP Service from a Terminal
To start the service from a terminal, use the following command, changing the service name if necessary:
net start JBossEAP7
To stop the service from a terminal, use the following command, changing the service name if necessary:
net stop JBossEAP7
If you want to remove the JBoss EAP service, use the following procedure.
Removing the JBoss EAP Service in Microsoft Windows Server
If the service is running, first open a terminal and stop the service by executing the
net stop
command with the name of the service:net stop JBossEAP7
In a terminal, change directories to
EAP_HOME\bin
and execute the following command:service.bat uninstall
4.4. Configuring JBoss EAP as a Service Using Jsvc
The Apache Jsvc component of the JBoss Core Services collection can be used to run JBoss EAP as a background service on Red Hat Enterprise Linux and Solaris.
Jsvc support for JBoss EAP is primarily intended for running JBoss EAP as a service on Microsoft Windows and Solaris. Although Jsvc works on Red Hat Enterprise Linux, we strongly recommend that you use the native methods for running JBoss EAP as a service on Red Hat Enterprise Linux.
Jsvc is a set of libraries and applications which allow Java applications to run on UNIX-like platforms as a background service. It allows an application to perform operations as a privileged user, and then switch identity to a non-privileged user.
Jsvc uses three processes: a launcher process, a controller process, and a controlled process. The controlled process is also the main Java thread. If the JVM crashes, the controller process will restart it within 60 seconds. Jsvc is a daemon process, and for JBoss EAP it must be started by a privileged user.
Install the JBoss Core Services Jsvc Package
For ZIP or installer installations:
- Open a browser and log in to the Red Hat Customer Portal JBoss Software Downloads page.
- Select Apache Jsvc in the Product drop-down menu.
- Select the latest version from the Version drop-down menu.
- Find Red Hat JBoss Core Services Apache Jsvc in the list, ensuring that you select the correct platform and architecture for your system, and click the Download link.
Extract the downloaded ZIP file into the directory containing your JBoss EAP installation directory.
This will result in a
jbcs-jsvc-<VERSION>
directory at the same depth as your JBoss EAP installation directory. For example:/var/opt/ ├── jboss-eap-7.3 │ ├── bin │ └── ... └── jbcs-jsvc-<VERSION>
The command examples for using Jsvc to start JBoss EAP assume that a
jboss
user has been created. If you have not already created a user for JBoss EAP, run the following commands to create thejboss
user and group:# groupadd -f -g 185 -r jboss # useradd -r -u 185 -g jboss -d EAP_HOME -s /sbin/nologin -c "JBoss" jboss
For RPM installations on Red Hat Enterprise Linux:
- Log in to Red Hat Subscription Manager.
- Click on Systems in the Subscriber Inventory.
Subscribe to the JBoss Core Services CDN repositories for your operating system version and architecture:
For Red Hat Enterprise Linux 6:
- jb-coreservices-1-for-rhel-6-server-rpms
For Red Hat Enterprise Linux 7 and later:
- jb-coreservices-1-for-rhel-7-server-rpms
Run the following command as the root user to install Jsvc:
# yum groupinstall jbcs-jsvc
Be sure to set the JAVA_HOME
system environment variable.
Using Jsvc to Start JBoss EAP as a Standalone Server
The following commands are used are to start and stop JBoss EAP in standalone mode using Jsvc. The tables below show the paths that are needed for the commands for a ZIP/installer JBoss EAP installation, or an RPM installation.
File Reference in Instructions | File Location |
---|---|
|
|
|
|
|
|
|
|
File Reference in Instructions | File Location |
---|---|
|
|
|
|
|
|
|
|
Start a standalone JBoss EAP server using Jsvc:
$ JSVC_BIN \ -outfile LOG_DIR/jsvc.out.log \ -errfile LOG_DIR/jsvc.err.log \ -pidfile LOG_DIR/jsvc.pid \ -user jboss \ -D[Standalone] -XX:+UseCompressedOops -Xms1303m \ -Xmx1303m -XX:MaxPermSize=256m \ -Djava.net.preferIPv4Stack=true \ -Djboss.modules.system.pkgs=org.jboss.byteman \ -Djava.awt.headless=true \ -Dorg.jboss.boot.log.file=LOG_DIR/server.log \ -Dlogging.configuration=file:CONF_DIR/logging.properties \ -Djboss.modules.policy-permissions \ -cp EAP_HOME/jboss-modules.jar:JSVC_JAR \ -Djboss.home.dir=EAP_HOME \ -Djboss.server.base.dir=EAP_HOME/standalone \ @org.jboss.modules.Main -start-method main \ -mp EAP_HOME/modules \ -jaxpmodule javax.xml.jaxp-provider \ org.jboss.as.standalone
Stop a standalone JBoss EAP server using Jsvc:
$ JSVC_BIN \ -stop \ -outfile LOG_DIR/jsvc.out.log \ -errfile LOG_DIR/jsvc.err.log \ -pidfile LOG_DIR/jsvc.pid \ -user jboss \ -D[Standalone] -XX:+UseCompressedOops -Xms1303m \ -Xmx1303m -XX:MaxPermSize=256m \ -Djava.net.preferIPv4Stack=true \ -Djboss.modules.system.pkgs=org.jboss.byteman \ -Djava.awt.headless=true \ -Dorg.jboss.boot.log.file=LOG_DIR/server.log \ -Dlogging.configuration=file:CONF_DIR/logging.properties \ -Djboss.modules.policy-permissions \ -cp EAP_HOME/jboss-modules.jar:JSVC_JAR \ -Djboss.home.dir=EAP_HOME \ -Djboss.server.base.dir=EAP_HOME/standalone \ @org.jboss.modules.Main -start-method main \ -mp EAP_HOME/modules \ -jaxpmodule javax.xml.jaxp-provider \ org.jboss.as.standalone
Using Jsvc to Start a JBoss EAP Managed Domain
The following commands are used are to start and stop a JBoss EAP managed domain using Jsvc. The tables below show the paths that are needed for the commands for a ZIP/installer JBoss EAP installation, or an RPM installation.
File Reference in Instructions | File Location |
---|---|
|
|
|
|
|
|
|
|
File Reference in Instructions | File Location |
---|---|
|
|
|
|
|
|
|
|
Before you issue the following command, be sure to set the JAVA_HOME
system environment variable.
Start a JBoss EAP managed domain using Jsvc:
$ JSVC_BIN \ -outfile LOG_DIR/jsvc.out.log \ -errfile LOG_DIR/jsvc.err.log \ -pidfile LOG_DIR/jsvc.pid \ -user jboss \ -nodetach -D"[Process Controller]" -server -Xms64m \ -Xmx512m -XX:MaxPermSize=256m \ -Djava.net.preferIPv4Stack=true \ -Djboss.modules.system.pkgs=org.jboss.byteman \ -Djava.awt.headless=true \ -Dorg.jboss.boot.log.file=LOG_DIR/process-controller.log \ -Dlogging.configuration=file:CONF_DIR/logging.properties \ -Djboss.modules.policy-permissions \ -cp "EAP_HOME/jboss-modules.jar:JSVC_JAR" \ org.apache.commons.daemon.support.DaemonWrapper \ -start org.jboss.modules.Main -start-method main \ -mp EAP_HOME/modules org.jboss.as.process-controller \ -jboss-home EAP_HOME -jvm "${JAVA_HOME}"/bin/java \ -mp EAP_HOME/modules -- \ -Dorg.jboss.boot.log.file=LOG_DIR/host-controller.log \ -Dlogging.configuration=file:CONF_DIR/logging.properties \ -Djboss.modules.policy-permissions \ -server -Xms64m -Xmx512m -XX:MaxPermSize=256m \ -Djava.net.preferIPv4Stack=true \ -Djboss.modules.system.pkgs=org.jboss.byteman \ -Djava.awt.headless=true -- -default-jvm "${JAVA_HOME}"/bin/java \ &
Stop a JBoss EAP managed domain using Jsvc:
$ JSVC_BIN \ -stop \ -outfile LOG_DIR/jsvc.out.log \ -errfile LOG_DIR/jsvc.err.log \ -pidfile LOG_DIR/jsvc.pid \ -user jboss \ -nodetach -D"[Process Controller]" -server -Xms64m \ -Xmx512m -XX:MaxPermSize=256m \ -Djava.net.preferIPv4Stack=true \ -Djboss.modules.system.pkgs=org.jboss.byteman \ -Djava.awt.headless=true \ -Dorg.jboss.boot.log.file=LOG_DIR/process-controller.log \ -Dlogging.configuration=file:CONF_DIR/logging.properties \ -Djboss.modules.policy-permissions \ -cp "EAP_HOME/jboss-modules.jar:JSVC_JAR" \ org.apache.commons.daemon.support.DaemonWrapper \ -start org.jboss.modules.Main -start-method main \ -mp EAP_HOME/modules org.jboss.as.process-controller \ -jboss-home EAP_HOME -jvm $JAVA_HOME/bin/java \ -mp EAP_HOME/modules -- \ -Dorg.jboss.boot.log.file=LOG_DIR/host-controller.log \ -Dlogging.configuration=file:CONF_DIR/logging.properties \ -Djboss.modules.policy-permissions \ -server -Xms64m -Xmx512m -XX:MaxPermSize=256m \ -Djava.net.preferIPv4Stack=true \ -Djboss.modules.system.pkgs=org.jboss.byteman \ -Djava.awt.headless=true -- -default-jvm $JAVA_HOME/bin/java