Chapter 2. Installing Red Hat JBoss Fuse as a Service


This chapter provides information on how you can start the Red Hat JBoss Fuse instance as a system service by using the templates.

2.1. Overview

By using the Service Script templates, you can run a fuse instance with the help of operating system specific init scripts. You can find these templates under the bin/contrib directory.

2.1.1. Running Fuse as a Service

The utility helps you to customize the templates. This utility will automatically identify the operating system and the default init system and generates ready to use init scripts. You can also customize the scripts to adapt them to its environment, by setting JAVA_HOME and few other environment variables.
The generated scripts are composed by two files:
  1. the init script
  2. the init configuration file

2.1.2. Customizing Utility

You can customize the utility, by defining an environment variable or by passing command line options:

Table 2.1. 

Command Line OptionEnvironment VariableDescription
-k KARAF_SERVICE_PATH Karaf installation path
-d KARAF_SERVICE_DATA Karaf data path (default to \${KARAF_SERVICE_PATH}/data)
-c KARAF_SERVICE_CONF Karaf configuration file (default to \${KARAF_SERVICE_PATH/etc/\${KARAF_SERVICE_NAME}.conf)
-t KARAF_SERVICE_ETC Karaf etc path (default to \${KARAF_SERVICE_PATH/etc})
-n KARAF_SERVICE_NAME Karaf service name (default karaf)
-e KARAF_ENV Karaf environment variable
-l KARAF_SERVICE_LOG Karaf console log (default to \${KARAF_SERVICE_DATA}/log/\${KARAF_SERVICE_NAME}-console.log)
-f KARAF_SERVICE_TEMPLATE Template file to use
-x KARAF_SERVICE_EXECUTABLE Karaf executable name (defaul karaf support daemon and stop commands)

2.1.3. Systemd

When the utility identifies Systemd, it generates three files:
  • a systemd unit file to manage the root Apache Karaf container
  • a systemd environment file with variables used by the root Apache Karaf container
  • a systemd template unit file to manage Apache Karaf child containers
Here is an example:
$ ./ -k /opt/karaf-4 -n karaf-4
Writing service file "/opt/karaf-4/bin/contrib/karaf-4.service"
Writing service configuration file ""/opt/karaf-4/etc/karaf-4.conf"
Writing service file "/opt/karaf-4/bin/contrib/karaf-4@.service"
$ cp /opt/karaf-4/bin/contrib/karaf-4.service /etc/systemd/system
$ cp /opt/karaf-4/bin/contrib/karaf-4@.service /etc/systemd/system
$ systemctl enable karaf-4.service

2.1.4. SysV

When the utility identifies a SysV system, it generates two files:
  • an init script to manage the root Apache Karaf container
  • an environment file with variables used by the root Apache Karaf container
Here is an example:
$ ./ -k /opt/karaf-4 -n karaf-4
Writing service file "/opt/karaf-4/bin/contrib/karaf-4"
Writing service configuration file "/opt/karaf-4/etc/karaf-4.conf"
$ ln -s /opt/karaf-4/bin/contrib/karaf-4 /etc/init.d/
$ chkconfig karaf-4 on
To enable the service startup upon boot, Refer your operating system init guide.

2.1.5. Solaris SMF

When the utility identifies a Solaris operating system, it generates a single file.
Here is an example:
$ ./ -k /opt/karaf-4 -n karaf-4
Writing service file "/opt/karaf-4/bin/contrib/karaf-4.xml"
$ svccfg validate /opt/karaf-4/bin/contrib/karaf-4.xml
$ svccfg import /opt/karaf-4/bin/contrib/karaf-4.xml

The generated SMF descriptor is defined as transient, so that you can execute the start method only once.

2.1.6. Windows

Installation of Apache Karaf as windows service is supported through winsw.
To install Apache Karaf as windows service, perform the following:
  • Rename the karaf-service-win.exe file to karaf-4.exe file.
  • Rename the karaf-service-win.xml file to karaf-4.xml file.
  • Customize the service descriptor as per your requirements.
  • Use the service executable to install, start and stop the service.
Here is an example:
C:\opt\apache-karaf-4\bin\contrib> karaf-4.exe install
C:\opt\apache-karaf-4\bin\contrib> karaf-4.exe start