Red Hat Training

A Red Hat training course is available for Red Hat JBoss Enterprise Application Platform

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

  • Install JBoss EAP as a ZIP or Installer installation.
  • Administrator privileges on the server.

Configuring JBoss EAP as a Service in Red Hat Enterprise Linux

  1. 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. Open jboss-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 for JBOSS_HOME and the JBOSS_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.

    Note

    If you want the service to start JBoss EAP as a managed domain, add JBOSS_MODE=domain to jboss-eap.conf.

    To specify custom domain configuration files, add JBOSS_DOMAIN_CONFIG=DOMAIN_CONFIG_FILE.xml and JBOSS_HOST_CONFIG=HOST_CONFIG_FILE.xml. By default, JBoss EAP uses domain.xml and host.xml as the domain configuration files.

  2. Copy the service files into the system directories.

    1. Copy the modified service configuration file to the /etc/default directory.

      $ sudo cp EAP_HOME/bin/init.d/jboss-eap.conf /etc/default
    2. 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
  3. Add the new jboss-eap-rhel.sh service to list of automatically started services using the chkconfig service management command:

    $ sudo chkconfig --add jboss-eap-rhel.sh
  4. Test that the service has been installed correctly by using one of the following commands.

    1. For Red Hat Enterprise Linux 6:

      $ sudo service jboss-eap-rhel.sh start
    2. For Red Hat Enterprise Linux 7:

      $ 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.

  5. 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

  1. If the service is running, open a terminal and stop the service with one of the following commands.

    1. For Red Hat Enterprise Linux 6:

      $ sudo service jboss-eap-rhel.sh stop
    2. For Red Hat Enterprise Linux 7:

      $ sudo service jboss-eap-rhel stop
  2. Remove JBoss EAP from the list of services:

    $ sudo chkconfig --del jboss-eap-rhel.sh
  3. 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.
Important

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:

    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.

Note

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

  • Install JBoss EAP as a ZIP or Installer installation.
  • Administrator privileges on the server.
  • The JAVA_HOME system environment variable must be set.
  • The JBoss EAP server instance must not be running.
Important

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

  1. Create two system environment variables:

    • JBOSS_HOME pointing to the JBoss EAP installation directory.
    • NOPAUSE=1
  2. Install the JBoss Core Services Jsvc Package

    If not already configured, download and extract the JBoss Core Services Jsvc package.

    1. Open a browser and log in to the Red Hat Customer Portal JBoss Software Downloads page.
    2. Select Apache Jsvc in the Product drop-down menu.
    3. Select the latest version from the Version drop-down menu.
    4. 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.
    5. 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.1
      │   ├── bin
      │   └── ...
      └── jbcs-jsvc-<VERSION>
  3. 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, run service.bat without any arguments.

    Important

    If 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:

    1. For a standalone server:

      service.bat install /loglevel INFO
    2. 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 executing ls /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 to master.

      service.bat install /host EAP_HOST_NAME /loglevel INFO

    A new Windows service will be created with name JBossEAP7.

  4. Verify the New Service in the Services console

    Open 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.

  5. 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

  1. 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
  2. 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.

Note

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:

    1. Open a browser and log in to the Red Hat Customer Portal JBoss Software Downloads page.
    2. Select Apache Jsvc in the Product drop-down menu.
    3. Select the latest version from the Version drop-down menu.
    4. 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.
    5. 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.1
      │   ├── bin
      │   └── ...
      └── jbcs-jsvc-<VERSION>
    6. 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 the jboss 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:

    1. Log in to Red Hat Subscription Manager.
    2. Click on Systems in the Subscriber Inventory.
    3. Subscribe to the JBoss Core Services CDN repositories for your operating system version and architecture:

      1. For Red Hat Enterprise Linux 6:

        • jb-coreservices-1-for-rhel-6-server-rpms
      2. For Red Hat Enterprise Linux 7:

        • jb-coreservices-1-for-rhel-7-server-rpms
    4. Run the following command as the root user to install Jsvc:

      # yum groupinstall jbcs-jsvc
Note

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.

Table 4.1. Jsvc File Locations for ZIP/Installer Installations - Standalone Server

File Reference in InstructionsFile Location

JSVC_BIN

EAP_HOME/../jbcs-jsvc-<VERSION>/sbin/jsvc

JSVC_JAR

EAP_HOME/../jbcs-jsvc-<VERSION>/lib/commons-daemon.jar

CONF_DIR

EAP_HOME/standalone/configuration

LOG_DIR

EAP_HOME/standalone/log

Table 4.2. Jsvc File Locations for RPM Installations - Standalone Server

File Reference in InstructionsFile Location

JSVC_BIN

/usr/bin/jbcs-jsvc/jsvc

JSVC_JAR

/usr/bin/jbcs-jsvc/commons-daemon.jar

CONF_DIR

/opt/rh/eap7/root/usr/share/wildfly/standalone/configuration

LOG_DIR

/opt/rh/eap7/root/usr/share/wildfly/standalone/log

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.

Table 4.3. Jsvc File Locations for ZIP/Installer Installations - Managed Domain

File Reference in InstructionsFile Location

JSVC_BIN

EAP_HOME/../jbcs-jsvc-<VERSION>/sbin/jsvc

JSVC_JAR

EAP_HOME/../jbcs-jsvc-<VERSION>/lib/commons-daemon.jar

CONF_DIR

EAP_HOME/domain/configuration

LOG_DIR

EAP_HOME/domain/log

Table 4.4. Jsvc File Locations for RPM Installations - Managed Domain

File Reference in InstructionsFile Location

JSVC_BIN

/usr/bin/jbcs-jsvc/jsvc

JSVC_JAR

/usr/bin/jbcs-jsvc/commons-daemon.jar

CONF_DIR

/opt/rh/eap7/root/usr/share/wildfly/domain/configuration

LOG_DIR

/opt/rh/eap7/root/usr/share/wildfly/domain/log

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