Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 4. Installing Apache Karaf as a Service
This chapter provides information on how you can start an Apache Karaf instance as a system service using the provided templates.
4.1. Overview Copier lienLien copié sur presse-papiers!
Using the service script templates, you can run a Karaf instance with the help of operating system specific init scripts. You can find these templates under the bin/contrib
directory.
4.2. Running Karaf as a Service Copier lienLien copié sur presse-papiers!
The karaf-service.sh
utility helps you to customize the templates. This utility automatically identifies 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 the environment, by setting JAVA_HOME
and a few other environment variables.
The generated scripts are composed of two files:
- The init script
- The init configuration file
4.3. Systemd Copier lienLien copié sur presse-papiers!
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. -
(Not supported) A
systemd
template unit file to manage Apache Karaf child containers.
For example, to set up a service for a Karaf instance installed at /opt/karaf-4
, giving the service the name, karaf-4
:
4.4. SysV Copier lienLien copié sur presse-papiers!
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.
For example, to set up a service for a Karaf instance installed at /opt/karaf-4
, giving the service the name, karaf-4
:
./karaf-service.sh -k /opt/karaf-4 -n karaf-4 sudo ln -s /opt/karaf-4/bin/contrib/karaf-4 /etc/init.d/ sudo chkconfig karaf-4 on
$ ./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"
$ sudo ln -s /opt/karaf-4/bin/contrib/karaf-4 /etc/init.d/
$ sudo chkconfig karaf-4 on
To enable the service startup upon boot, refer to your operating system init guide.
4.5. Solaris SMF Copier lienLien copié sur presse-papiers!
When the karaf-service.sh
utility identifies a Solaris operating system, it generates a single file.
For example, to set up a service for a Karaf instance installed at /opt/karaf-4
, giving the service the name, karaf-4
:
./karaf-service.sh -k /opt/karaf-4 -n karaf-4 sudo svccfg validate /opt/karaf-4/bin/contrib/karaf-4.xml sudo svccfg import /opt/karaf-4/bin/contrib/karaf-4.xml
$ ./karaf-service.sh -k /opt/karaf-4 -n karaf-4
Writing service file "/opt/karaf-4/bin/contrib/karaf-4.xml"
$ sudo svccfg validate /opt/karaf-4/bin/contrib/karaf-4.xml
$ sudo 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.
4.6. Windows Copier lienLien copié sur presse-papiers!
Installation of Apache Karaf as Windows service is supported through winsw
.
To install Apache Karaf as Windows service, perform the following steps:
-
Rename the
karaf-service-win.exe
file tokaraf-4.exe
. -
Rename the
karaf-service-win.xml
file tokaraf-4.xml
. - Customize the service descriptor as required.
- Use the service executable to install, start and stop the service.
For example:
karaf-4.exe install karaf-4.exe start
C:\opt\apache-karaf-4\bin\contrib> karaf-4.exe install
C:\opt\apache-karaf-4\bin\contrib> karaf-4.exe start
4.7. karaf-service.sh Options Copier lienLien copié sur presse-papiers!
You can specify options to the karaf-service.sh
utility either as command-line options or by setting environment variables, as follows:
Command Line Option | Environment Variable | Description |
---|---|---|
|
| Karaf installation path |
|
|
Karaf data path (defaults to |
|
|
Karaf configuration file (defaults to |
|
|
Karaf |
|
|
Karaf PID path (defaults to |
|
|
Karaf service name (defaults to |
|
|
Specifies an environment variable setting, |
|
| Karaf user |
|
|
Karaf group (defaults to |
|
|
Karaf console log (defaults to |
|
| Template file to use |
|
|
Karaf executable name (defaults to |
| Help message |