- Apache Karaf Cookbook
- Achim Nierbeck Jamie Goodyear Johan Edstrom Heath Kesler
- 496字
- 2021-09-03 09:55:08
Installing Apache Karaf as a service
When we install Apache Karaf, we'll want it to operate as a system service on our host platform (just like Windows or Linux). In this recipe, we'll set up Karaf to start when your system boots up.
Getting ready
The ingredients of this recipe include the Apache Karaf distribution kit, access to JDK, and a source code editor. The sample wrapper configuration for this recipe is available at https://github.com/jgoodyear/ApacheKarafCookbook/tree/master/chapter1/chapter1-recipe7.
How to do it…
- The first step is installing the service wrapper feature. Apache Karaf utilizes a service wrapper feature to handle gathering and deploying of the required resources for your host operating environment. We begin its installation by invoking the following command:
karaf@root()>feature:install service-wrapper
The service wrapper feature URL is included in Karaf by default; so, no additional step is required to make it available.
- The next step is installing the wrapper service. Now, we must instruct the wrapper to configure and install the appropriate service scripts and resources for us. Consider the following command:
karaf@root()>wrapper:install –s AUTO_START –n Karaf3 –D "Apache Karaf Cookbook"
The preceding
wrapper:install
command invocation includes three flags:-s
for the start type,-n
for the service name, and–D
for the service description. The start type can be one of two options:AUTO_START
, to automatically start the service on boot, andDEMAND_START
, to start only when manually invoked. The service name is used as an identifier in the host's service registry. The description provides system administrators with a brief description of your Karaf installation. After executing theinstall
command, the Karaf console will display the libraries, scripts, and configuration files that the wrapper generates. You'll now need to exit Karaf to continue the service installation. - The final step is integrating it in to the host operating system. This step will require administrator level permissions to execute the generated Karaf service wrapper installation scripts.
The following command installs the service natively into Windows:
C:> C:\Path\To\apache-karaf-3.0.0\bin\Karaf3-service.bat install
The following
net
commands allow an administrator to start or stop the Karaf service:C:> net start "Karaf3" C:> net stop "Karaf3"
Linux integration will vary based on distribution. The following commands will work on Debian- or Ubuntu-based systems:
jgoodyear@ubuntu1204:~$ ln –s /Path/To/apache-karaf-3.0.0/bin/Karaf3-service /etc/init.d jgoodyear@ubuntu1204:~$ update-rc.d Karaf3-service defaults jgoodyear@ubuntu1204:~$ /etc/init.d/Karaf3-service start jgoodyear@ubuntu1204:~$ /etc/init.d/Karaf3-service stop
The first command creates a symbolic link from the service script in Karaf's
bin
folder to theinit.d
directory and then updates the startup scripts to include the Karaf service to automatically start during boot. The remaining two commands can be used to manually start or stop the Karaf service.
How it works…
The wrapper service feature integrates Karaf into the host operating system's service mechanism. This means that on a Windows- or Linux-based system, Karaf will avail of the available fault, crash, processing freeze, out of memory, or similar event detections and automatically attempt to restart Karaf.
See also
- The Setting up Apache Karaf for high availability recipe
- DevOps:軟件架構(gòu)師行動(dòng)指南
- 復(fù)雜軟件設(shè)計(jì)之道:領(lǐng)域驅(qū)動(dòng)設(shè)計(jì)全面解析與實(shí)戰(zhàn)
- JIRA 7 Administration Cookbook(Second Edition)
- Symfony2 Essentials
- Learning Zurb Foundation
- 深入理解Android:Wi-Fi、NFC和GPS卷
- Node.js全程實(shí)例
- NetBeans IDE 8 Cookbook
- Java實(shí)戰(zhàn)(第2版)
- 單片機(jī)原理及應(yīng)用技術(shù)
- ActionScript 3.0從入門到精通(視頻實(shí)戰(zhàn)版)
- SpringBoot從零開始學(xué)(視頻教學(xué)版)
- 深入淺出Python數(shù)據(jù)分析
- PostgreSQL Developer's Guide
- 3D Printing Designs:The Sun Puzzle