此内容没有您所选择的语言版本。
Chapter 2. Installing Red Hat JBoss Fuse as a Service
Abstract
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 karaf-service.sh 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:
- the init script
- the init configuration file
2.1.2. Customizing karaf-service.sh Utility
You can customize the karaf-service.sh utility, by defining an environment variable or by passing command line options:
Command Line Option | Environment Variable | Description |
---|---|---|
-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} ) |
-p | KARAF_SERVICE_PIDFILE | Karaf pid path (default to \${KARAF_SERVICE_DATA}/\${KARAF_SERVICE_NAME}.pid) ) |
-n | KARAF_SERVICE_NAME | Karaf service name (default karaf) |
-e | KARAF_ENV | Karaf environment variable |
-u | KARAF_SERVICE_USER | Karaf user |
-g | KARAF_SERVICE_GROUP | Karaf group (default \${KARAF_SERVICE_USER ) |
-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) |
CONF_TEMPLATE="karaf-service-template.conf" SYSTEMD_TEMPLATE="karaf-service-template.systemd" SYSTEMD_TEMPLATE_INSTANCES="karaf-service-template.systemd-instances" INIT_TEMPLATE="karaf-service-template.init" INIT_REDHAT_TEMPLATE="karaf-service-template.init-redhat" INIT_DEBIAN_TEMPLATE="karaf-service-template.init-debian" SOLARIS_SMF_TEMPLATE="karaf-service-template.solaris-smf"
2.1.3. Systemd
When the
karaf-service.sh
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:
$ ./karaf-service.sh -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
karaf-service.sh
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:
$ ./karaf-service.sh -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
Note
To enable the service startup upon boot, Refer your operating system init guide.
2.1.5. Solaris SMF
When the karaf-service.sh utility identifies a Solaris operating system, it generates a single file.
Here is an example:
$ ./karaf-service.sh -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
Note
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 tokaraf-4.exe
file. - Rename the
karaf-service-win.xml
file tokaraf-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