Red Hat Training

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

2.10. Service Configuration

2.10.1. Configure JBoss EAP 6 as a Service in Red Hat Enterprise Linux (RPM Method)

Prerequisites

Important

It is not supported to configure more than one JBoss EAP instance as a system service on a single machine.
Summary

Use the following procedure to install JBoss EAP 6 as a service on Red Hat Enterprise Linux when the installation has been done using the RHN (RPM) method.

Procedure 2.17. Configure JBoss EAP 6 as a Service using the RPM Method in Red Hat Enterprise Linux

  1. Install JBoss EAP 6

    Install JBoss EAP 6 via the RPM method using one of the steps listed in the prerequisite sections listed above.
  2. Enable the service

    The RPM install method for JBoss EAP 6 installs the requisite service files in their correct locations. All you need to do to set it up as service is issue the following command:
    chkconfig jbossas on
    To set it up as a service in domain mode, issue the following command:
    chkconfig jbossas-domain on
Result

JBoss EAP 6 starts automatically when the Red Hat Enterprise Linux reaches its default run-level, and stops automatically when the operating system goes through its shutdown routine.

2.10.2. Configure JBoss EAP 6 as a Service in Red Hat Enterprise Linux (Zip, Installer)

Prerequisites

Summary

Use the following procedure to install JBoss EAP 6 as a service on Red Hat Enterprise Linux when the installation has been done with either the zip, text, or graphical methods. This process does not apply when the installation has been done using the RHN (RPM) method.

Procedure 2.18. Set Up the Service

Note

The steps below describe running JBoss EAP 6 as a service in standalone mode. In order to run JBoss EAP 6 as a service in domain mode, use the same steps but replace jboss-as-standalone.sh with jboss-as-domain.sh.
  1. Locate the start-up script and configuration file

    The start-up script and an associated configuration file are located in the EAP_HOME/bin/init.d/ directory.
  2. Customize the start-up options in the jboss-as.conf file

    Open the file jboss-as.conf in a text editor. There are several options within the jboss-as.conf file. At the minimum, specify the correct values for JBOSS_HOME and the JBOSS_USER variables. If these variables are absent, add them.
  3. Copy files into system directories

    1. Create the /etc/jboss-as directory if it doesn't already exist.
      sudo mkdir /etc/jboss-as
    2. Copy the modified configuration file to the /etc/jboss-as directory.
      sudo cp EAP_HOME/bin/init.d/jboss-as.conf /etc/jboss-as
    3. Copy the start-up script to the /etc/init.d directory.
      sudo cp EAP_HOME/bin/init.d/jboss-as-standalone.sh /etc/init.d
      To make the start-up script executable.
      sudo chmod +x /etc/init.d/jboss-as-standalone.sh
  4. Add the start-up script as a service.

    Add the new jboss-as-standalone.sh service to list of automatically started services, using the chkconfig service management command.
    sudo chkconfig --add jboss-as-standalone.sh
  5. Start the service.

    Test that the service has been installed correctly by using one of the following commands for Red Hat Enterprise Linux.
    • For Red Hat Enterprise Linux 5 and 6:
      sudo service jboss-as-standalone.sh start
    • For Red Hat Enterprise Linux 7:
      sudo service jboss-as-standalone start
    If everything has gone correctly, you should get a green [OK]. If you get an error, check the error logs and make sure your paths are correct in the configuration file.

    Note

    The green [OK] does not appear for Red Hat Enterprise Linux 7.
  6. Make the service start automatically when you restart your server.

    To add the service to the list of services which start automatically when your server restarts, issue the following command.
    sudo chkconfig jboss-as-standalone.sh on
Result

JBoss EAP 6 starts automatically when the Red Hat Enterprise Linux reaches its default run-level, and stops automatically when the operating system goes through its shutdown routine.

Procedure 2.19. Uninstall the JBoss EAP 6 service from Red Hat Enterprise Linux

Note

The steps below describe uninstalling the JBoss EAP 6 service in standalone mode. In order to uninstall the JBoss EAP 6 service in domain mode, use the same steps but replace jboss-as-standalone.sh with jboss-as-domain.sh.
  1. If the service is running, first open a terminal and stop the service by executing the stop command with the name of the service:
    sudo service jboss-as-standalone.sh stop
  2. Remove JBoss EAP from the list of services:
    sudo chkconfig --del jboss-as-standalone.sh
  3. Remove the system directory files.
    1. Remove the service start-up script:
      sudo rm /etc/init.d/jboss-as-standalone.sh
    2. Remove the service configuration file:
      sudo rm /etc/jboss-as/jboss-as.conf

      Important

      /etc/jboss-as is not a standard system directory. Only if there are no other files being used there, also remove the directory itself:
      sudo rm -rf /etc/jboss-as/
Result

JBoss EAP 6 service is uninstalled from the server.

2.10.3. Configure JBoss EAP 6 as a Service in Microsoft Windows Server (Zip, Installer)

Prerequisites

Important

When setting system environment variables, using the set command at 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.
Summary

Use the following procedures to configure JBoss EAP 6 as a service on Microsoft Windows Server.

Procedure 2.20. Configure a Service for JBoss EAP 6 in Microsoft Windows Server

  1. Create system environment variables

    Create two system environment variables:
    • JBOSS_HOME pointing to the JBoss EAP 6 installation directory.
    • NOPAUSE=1
  2. If not already configured, download and extract the Native Utilities package for your architecture

    If the Native Utilities for Windows Server package has not been installed as part of the JBoss EAP 6 installation, download the relevant 32-bit or 64-bit package from the Red Hat Customer Portal at https://access.redhat.com. Extract the Native Utilities zip archive over the JBoss EAP 6 installation.
    This will result in a native directory in the following location in the JBoss EAP 6 installation: EAP_HOME\modules\system\layers\base\
  3. Install the service

    Open a terminal, and change directories to EAP_HOME\modules\system\layers\base\native\sbin
    A new service can be created with the service install command, with the available options shown in the following table.

    Table 2.4. service install options

    Argument or Switch Description
    /startup
    Indicates the services to auto start. If not specified, the service is set to be started manually.
    /controller HOST:PORT
    The host and port of the management interface. If omitted, the default is localhost:9999.
    /host [DOMAIN_HOST]
    Indicates that domain mode is to be used, with an optional host controller name. If the host controller name is omitted, the default name master is used.
    /loglevel LEVEL
    The log level for the service, either: ERROR, INFO, WARN or DEBUG. If omitted, the default is INFO
    /name SERVICE_NAME
    The name of the service to be created, must not contain spaces. If omitted, the default is JBossEAP6
    /desc "DESCRIPTION"
    The description of the service. If omitted, the default is "JBoss Enterprise Application Platform 6"
    /serviceuser DOMAIN\USERNAME
    Specifies the name of the account under which the service will run. Use an account name in the format of DOMAIN\USERNAME. If omitted, the service runs as the Local System account.
    /servicepass PASSWORD
    Password for /serviceuser account.
    /jbossuser USERNAME
    Optional, the JBoss EAP 6 username to use for the shutdown command.
    /jbosspass PASSWORD
    Password for /jbossuser account, required if /jbossuser is specified.
    /config XML_FILE
    Specifies the server-config to use. The default is standalone.xml or domain.xml.
    /hostconfig XML_FILE
    Specifies the host config to use in Domain mode only. The default is host.xml.
    /base directory
    Specifies the base directory for server/domain content as a fully qualified path. The default is %JBOSS_HOME%\standalone or %JBOSS_HOME%\domain.
    /logpath path
    Specifies the path of the log files. /base applies when /logpath is not defined. The default depends on the domain mode or standalone mode, %JBOSS_HOME%\domain\log or %JBOSS_HOME%\standalone\log.
    /debug
    Runs the service install in debug mode.
    Below are basic examples of an install command to create a new service in either standalone or domain mode. Execute the following command, adjusting the log level for the service as required:
    • Standalone mode:
      service.bat install /loglevel INFO
    • Domain mode:
      If you are not using the default master for your JBoss EAP 6 domain controller, replace master with the correct host name or alias of the JBoss EAP 6 domain controller.
      service.bat install /host master /loglevel INFO
    A new Windows service will be created with name JBossEAP6.
  4. Verify the new service in the Services console

    Execute the following command in a terminal to open the Windows Services console:
    services.msc
    If the default service name was used, in the list of Windows services, the new service will have the display name: JBossEAP6. From the Services console you can start and stop the service, as well change its settings on how and when it starts.
  5. Starting and stopping the JBoss EAP 6 service from a terminal

    To start the service from a terminal, use the following command, changing the service name if necessary:
    net start JBossEAP6
    To stop the service from a terminal, use the following command, changing the service name if necessary:
    net stop JBossEAP6
Result

A JBoss EAP 6 service is configured in Microsoft Windows Server.

Procedure 2.21. Uninstall the JBoss EAP 6 service from 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 JBossEAP6
    In a terminal, change directories to EAP_HOME\modules\system\layers\base\native\sbin and execute the following command:
    service uninstall
Result

The JBoss EAP 6 service has been removed from Microsoft Windows Server.