-
Book Overview & Buying
-
Table Of Contents
APACHE KARAF COOKBOOK
By :
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.
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.
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.
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, and DEMAND_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 the install 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 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 the init.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.
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.
Change the font size
Change margin width
Change background colour