Chapter 2. Installing Red Hat JBoss Fuse as a System Service


Abstract

You can install JBoss Fuse as a system service in standalone mode or in fabric mode. The process, which varies between the two modes, involves installing and configuring the wrapper feature.

2.1. Installing Red Hat JBoss Fuse as a Service in Standalone Mode

Abstract

To install JBoss Fuse as a system service in standalone mode, you generate a service wrapper, configure the wrapper for your system, and then install and start the service. You can set optional environment variables that control aspects of the script that installs and removes the service.

2.1.1. Generating the Service Wrapper

Overview

The Red Hat JBoss Fuse console wrapper feature generates a wrapper around the JBoss Fuse runtime instance. You use the wrapper to install the Apache Karaf container as a system service. The wrapper feature is not installed by default in the console, so before you can generate the service wrapper you must install the wrapper feature.
After the feature is installed the console gains a wrapper:install command. Running this command generates a generic service wrapper in the JBoss Fuse installation.

Generating the service wrapper

  1. Start JBoss Fuse in console mode with the fuse command.
  2. Enter features:install wrapper.
    The features:install command locates the required libraries to provision the wrapper feature and deploys it into the runtime instance.
  3. Generate the wrapper with the wrapper:install command in the following format:
      wrapper:install -n <serviceName> -d <displayName> -D <<description>
    The Table 2.1, “Wrapper Install Options” table describes the wrapper:install options.
    Table 2.1. Wrapper Install Options
    OptionDefaultDescription
    -sAUTO_START(Windows only) Specifies the mode in which the service is installed. Valid values are AUTO_START or DEMAND_START.
    -nkarafSpecifies the service name that will be used when installing the service.
    -d Specifies the display name of the service.
    -D Specifies the description of the service.
    -i --include Specifies an include statement for the JSW wrapper configuration. To specify multiple include statement, enter this option multiple times.
    -e --env Specifies environment variable and values. To set multiple environment variable and values, enter this option multiple times.

Results

The wrapper:install command generates the following wrapper files:
  • bin\ServiceName-wrapper[.exe]—the executable file for the wrapper.
  • bin\ServiceName-service[.bat]—the script used to install and remove the service.
  • etc\ServiceName-wrapper.conf—the wrapper configuration file.
The command also creates the following libraries that the service wrapper requires:
  • lib\libwrapper.so
  • lib\karaf-wrapper.jar
  • lib\karaf-wrapper-main.jar

2.1.2. Configuring the Batch Script

Overview

You can set optional environment variables in the ServiceName-service[.bat] file to control the script execution priority and system user assignment.

RUN_AS_USER

You can set the RUN_AS_USER variable to instruct the script to run from a specific user account. For example, to run the script as the user mquser, uncomment the line #RUN_AS_USER and set the value as follows:
RUN_AS_USER=mquser
Important
Make sure that the specified user has the required privileges to write the PID file and wrapper.log files. If you attempt to run the script from a user that cannot write the log file, the wrapper will exit without logging an error message.
Important
The RUN_AS_USER variable must not be used with Solaris.

PRIORITY

If you run the script on a UNIX or LINUX operating system, you can se the PRIORITY environment variable to control the nice level of the service.

2.1.3. Configuring the Service Wrapper

Overview

You can configure the service wrapper in the ServiceName-wrapper.conf file, which is located under the InstallDir/etc/ directory.
For example, you might want to change any of the following settings:
  • default environment settings
  • properties passed to the JVM
  • Classpath
  • JMX settings
  • logging settings

Default environment settings

The following environment variables determine the broker environment:
JAVA_HOME
Location of the Java runtime installation.
Note
On Windows, you can set JAVA_HOME either as a system variable only in the registry or in ServiceName-wrapper.conf. You cannot set the variable as a regular environment variable in the Environment Variables list.
KARAF_HOME
Location of the Red Hat JBoss Fuse installation.
KARAF_BASE
Location of the configuration data and OSGi data for the broker instance.
Note
Runtime OSGi data is stored in sub-directories of this directory.
KARAF_DATA
Location of the logging and persistance data for the broker instance.
Example 2.1, “Default Environment Settings” describes the default environment variable values.

Example 2.1. Default Environment Settings

set.default.KARAF_HOME=InstallDir
set.default.KARAF_BASE=InstallDir
set.default.KARAF_DATA=InstallDir\data

JVM parameters

If you want to pass parameters to the JVM, you set the wrapper properties in the following format:
wrapper.java.additional.<param_sequence_number>
The parameter sequence number must be unique for each parameter.
You can also set Java system properties in the following format:
wrapper.java.additional.<n>=-DPropName=PropValue
Example 2.2, “Default Java System Properties” shows the default Java properties.

Example 2.2. Default Java System Properties

# JVM
# note that n is the parameter number starting from 1.
wrapper.java.additional.1=-Dkaraf.home="%KARAF_HOME%"
wrapper.java.additional.2=-Dkaraf.base="%KARAF_BASE%"
wrapper.java.additional.3=-Dkaraf.data="%KARAF_DATA%"
wrapper.java.additional.4=-Dcom.sun.managment.jmxremote
wrapper.java.additional.5=-Dkaraf.startLocalConsole=false
wrapper.java.additional.6=-Dkaraf.startRemoteShell=true
wrapper.java.additional.7=-Djava.endorsed.dirs="%JAVA_HOME%/jre/lib/endorsed;%JAVA_HOME%/lib/endorsed;%KARAF_HOME%/lib/endorsed"
wrapper.java.additional.8=-Djava.ext.dirs="%JAVA_HOME%/jre/lib/ext;%JAVA_HOME%/lib/ext;%KARAF_HOME%/lib/ext"

Additional classpath entries

You add classpath entries with the syntax format:
 wrapper.java.classpath.<n>
The sequence number must be unique for each classpath entry.
Example 2.3, “Default Wrapper Classpath” shows the default classpath entries.

Example 2.3. Default Wrapper Classpath

wrapper.java.classpath.1=%KARAF_BASE%/lib/karaf-wrapper.jar
wrapper.java.classpath.2=%KARAF_HOME%/lib/karaf.jar
wrapper.java.classpath.3=%KARAF_HOME%/lib/karaf-jaas-boot.jar
wrapper.java.classpath.4=%KARAF_BASE%/lib/karaf-wrapper-main.jar

JMX configuration properties

The default service wrapper configuration does not enable JMX. However, it includes template properties that you can set to enable JMX. For example, you can change the settings to use a different port or secure the JMX connection.
Example 2.4, “Wrapper JMX Properties” shows the JMX template properties.

Example 2.4. Wrapper JMX Properties

#wrapper.java.additional.n=-Dcom.sun.management.jmxremote.port=1616
#wrapper.java.additional.n=-Dcom.sun.management.jmxremote.authenticate=false
#wrapper.java.additional.n=-Dcom.sun.management.jmxremote.ssl=false
  1. Locate the following line: # Uncomment to enable jmx
  2. Remove the prefix # from each of the properties.
  3. Replace the n in each property with a sequence number. Make sure that the number adheres to the sequence of all parameters and properties in the configuration file.

Logging configuration

You can set logging properties to control the level, frequency, and behavior of the wrapper logs.
Table 2.2, “Wrapper Logging Properties” lists the default logging properties.
Table 2.2. Wrapper Logging Properties
PropertyDescription
wrapper.console.format
Specifies how the logging information sent to the console is formated. The format consists of the following tokens:
  • L—log level
  • P—prefix
  • D—thread name
  • T—time
  • Z—time in milliseconds
  • U—approximate uptime in seconds (based on internal tick counter)
  • M—message
wrapper.console.loglevelSpecifies the logging level displayed on the console.
wrapper.logfileSpecifies the file used to store the log.
wrapper.logfile.formatSpecifies how the logging information sent to the log file is formated.
wrapper.console.loglevelSpecifies the logging level sent to the log file.
wrapper.console.maxsizeSpecifies the maximum size, in bytes, that the log file can grow to before the log is archived. The default value of 0 disables log rolling.
wrapper.console.maxfilesSpecifies the maximum number of archived log files which will be allowed before old files are deleted. The default value of 0 implies no limit.
wrapper.syslog.loglevelSpecifies the logging level for the sys/event log output.

2.1.4. Installing and Starting the Service

Overview

The operating system determines the exact steps to complete the installation of Red Hat JBoss Fuse as a service. The wrapper:install command contains basic instructions for your operating system.

Windows

Installing the service
Run the following command:
InstallDir\bin\ServiceName-service.bat install
By default, the service will start when Windows starts. If you specified the DEMAND_START option, you need to start the service manually.
Uninstalling the service
Run the following command:
InstallDir\bin\ServiceName-service.bat remove
Starting the service
Run the following command:
net start "ServiceName"
You can also start the service from the Windows Service dialog box.
Stopping the service
Run the following command:
net stop "ServiceName"
You can also stop the service from the Windows Service dialog box.

Red Hat Enterprise Linux

Installing the service
Run the following commands:
# ln -s InstallDir/bin/ServiceName-service /etc/init.d/
# chkconfig ServiceName-service --add
# chkconfig ServiceName-service on
By default, the service will start when Red Hat Enterprise Linux starts.
Uninstalling the service
Run the following command:
#service ServiceName-service stop
# chkconfig ServiceName-service --del
# rm /etc/init.d/ServiceName-service
Starting the service
Run the following command:
service ServiceName-service start
Stopping the service
Run the following command:
service ServiceName-service stop

Ubuntu Linux

Installing the service
Run the following commands:
# ln -s InstallDir/bin/ServiceName-service /etc/init.d/
# update-rc.d ServiceName-service defaults
By default, the service will start when Red Hat Enterprise Linux starts.
Uninstalling the service
Run the following command:
#/etc/init.d/ServiceName-service stop
# rm /etc/init.d/ServiceName-service
Starting the service
Run the following command:
/etc/init.d/ServiceName-service startservice ServiceName-service start
Stopping the service
Run the following command:
/etc/init.d/ServiceName-service stop

Solaris

Installing the service
Create Symbolic Links in /etc/init.d:
# ln -s InstallDir/bin/ServiceName-service /etc/init.d/ServiceName-service
# ln -s ln /etc/init.d/ServiceName-service /etc/rcn.d/SxxServiceName-service
Note
In SxxServiceName, the xx is the sequence number of execution for the service in the rc directory.
By default, the service will start when Solaris starts.
Uninstalling the service
Run the following command:
#/etc/init.d/ServiceName-service stop
# rm /etc/init.d/ServiceName-service
Starting the service
Run the following command:
#/etc/init.d/ ./ServiceName-service start
Stopping the service
Run the following command:
/etc/init.d/ ./ServiceName-service stop
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.