검색

이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 4. Installing Apache Karaf as a Service

download PDF

This chapter provides information on how you can start an Apache Karaf instance as a system service using the provided templates.

4.1. Overview

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

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

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:

$ ./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"
$ sudo cp /opt/karaf-4/bin/contrib/karaf-4.service /etc/systemd/system
$ sudo systemctl enable karaf-4.service

4.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.

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
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
Note

To enable the service startup upon boot, refer to your operating system init guide.

4.5. Solaris SMF

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
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
Note

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

4.6. Windows

Installation of Apache Karaf as Windows service is supported through winsw.

To install Apache Karaf as Windows service, perform the following steps:

  1. Rename the karaf-service-win.exe file to karaf-4.exe.
  2. Rename the karaf-service-win.xml file to karaf-4.xml.
  3. Customize the service descriptor as required.
  4. Use the service executable to install, start and stop the service.

For example:

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

You can specify options to the karaf-service.sh utility either as command-line options or by setting environment variables, as follows:

Command Line OptionEnvironment VariableDescription

-k

KARAF_SERVICE_PATH

Karaf installation path

-d

KARAF_SERVICE_DATA

Karaf data path (defaults to ${KARAF_SERVICE_PATH}/data)

-c

KARAF_SERVICE_CONF

Karaf configuration file (defaults to ${KARAF_SERVICE_PATH}/etc/${KARAF_SERVICE_NAME}.conf)

-t

KARAF_SERVICE_ETC

Karaf etc path (defaults to ${KARAF_SERVICE_PATH}/etc})

-p

KARAF_SERVICE_PIDFILE

Karaf PID path (defaults to ${KARAF_SERVICE_DATA}/${KARAF_SERVICE_NAME}.pid)

-n

KARAF_SERVICE_NAME

Karaf service name (defaults to karaf)

-e

KARAF_ENV

Specifies an environment variable setting, NAME=VALUE, for the service (can be specified more than once)

-u

KARAF_SERVICE_USER

Karaf user

-g

KARAF_SERVICE_GROUP

Karaf group (defaults to ${KARAF_SERVICE_USER})

-l

KARAF_SERVICE_LOG

Karaf console log (defaults 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 (defaults to karaf — must support the daemon and stop commands)

-h

 

Help message

Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.