Repository: karaf
Updated Branches:
refs/heads/karaf-3.0.x ae8a985f4 -> 28f09c14d
[KARAF-3858] Add support of systemd in wrapper
Conflicts:
wrapper/command/src/main/java/org/apache/karaf/wrapper/commands/Install.java
wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/28f09c14
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/28f09c14
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/28f09c14
Branch: refs/heads/karaf-3.0.x
Commit: 28f09c14df7aac3851e042f81626254debb7182e
Parents: ae8a985
Author: Jean-Baptiste Onofré <[email protected]>
Authored: Tue Sep 15 11:13:22 2015 +0200
Committer: Jean-Baptiste Onofré <[email protected]>
Committed: Tue Sep 15 13:04:55 2015 +0200
----------------------------------------------------------------------
manual/src/main/webapp/users-guide/wrapper.conf | 46 ++++++++++++++------
.../apache/karaf/wrapper/commands/Install.java | 31 +++++++++++--
.../wrapper/internal/WrapperServiceImpl.java | 12 ++++-
.../karaf/wrapper/internal/unix/karaf-service | 4 ++
.../karaf/wrapper/internal/unix/karaf.service | 33 ++++++++++++++
5 files changed, 107 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/28f09c14/manual/src/main/webapp/users-guide/wrapper.conf
----------------------------------------------------------------------
diff --git a/manual/src/main/webapp/users-guide/wrapper.conf
b/manual/src/main/webapp/users-guide/wrapper.conf
index b9fb8e2..4922f6a 100644
--- a/manual/src/main/webapp/users-guide/wrapper.conf
+++ b/manual/src/main/webapp/users-guide/wrapper.conf
@@ -107,21 +107,21 @@ For instance, on a Ubuntu/Debian Linux system:
{code}
karaf@root()> wrapper:install
-Creating file: /opt/apache-karaf-3.0.0/bin/karaf-wrapper
-Creating file: /opt/apache-karaf-3.0.0/bin/karaf-service
-Creating file: /opt/apache-karaf-3.0.0/etc/karaf-wrapper.conf
-Creating file: /opt/apache-karaf-3.0.0/lib/libwrapper.so
-Creating file: /opt/apache-karaf-3.0.0/lib/karaf-wrapper.jar
-Creating file: /opt/apache-karaf-3.0.0/lib/karaf-wrapper-main.jar
+Creating file: /opt/apache-karaf-3.0.5/bin/karaf-wrapper
+Creating file: /opt/apache-karaf-3.0.5/bin/karaf-service
+Creating file: /opt/apache-karaf-3.0.5/etc/karaf-wrapper.conf
+Creating file: /opt/apache-karaf-3.0.5/lib/libwrapper.so
+Creating file: /opt/apache-karaf-3.0.5/lib/karaf-wrapper.jar
+Creating file: /opt/apache-karaf-3.0.5/lib/karaf-wrapper-main.jar
Setup complete. You may wish to tweak the JVM properties in the wrapper
configuration file:
- /opt/apache-karaf-3.0.0/etc/karaf-wrapper.conf
+ /opt/apache-karaf-3.0.5/etc/karaf-wrapper.conf
before installing and starting the service.
Ubuntu/Debian Linux system detected:
To install the service:
- $ ln -s /opt/apache-karaf-3.0.0/bin/karaf-service /etc/init.d/
+ $ ln -s /opt/apache-karaf-3.0.5/bin/karaf-service /etc/init.d/
To start the service when the machine is rebooted:
$ update-rc.d karaf-service defaults
@@ -142,13 +142,21 @@ Ubuntu/Debian Linux system detected:
You can note that {{wrapper:install}} command detected the running operating
system ("Ubuntu/Debian Linux system detected").
-You have a complete explanation and list of system commands to perform to
integrate Apache Karaf in your system:
+You have a complete explanation and list of system commands to perform to
integrate Apache Karaf in your systemV:
{code}
-ln -s /opt/apache-karaf-3.0.0/bin/karaf-service /etc/init.d/
+ln -s /opt/apache-karaf-3.0.5/bin/karaf-service /etc/init.d/
update-rc.d karaf-service defaults
{code}
+Karaf also supports systemd service, so you can use systemctl instead of
SystemV based service:
+
+{code}
+systemctl enable /opt/apache-karaf-3.0.5/bin/karaf.service
+{code}
+
+This will enable Karaf at system boot.
+
h2. Uninstall
The {{wrapper:install}} provides the system commands to perform to uninstall
the service/daemon).
@@ -159,6 +167,12 @@ For instance, on Ubuntu/Debian, to uninstall the Apache
Karaf service, you have
rm /etc/init.d/karaf-service
{code}
+If you prefered the systemd service instead of systemV:
+
+{code}
+systemctl disable karaf
+{code}
+
You can remove the "Wrapper Service" installer after that:
{code}
@@ -259,10 +273,10 @@ This is a example of generated {{etc/karaf-wrapper.conf}}
file:
# Wrapper Properties
#********************************************************************
set.default.JAVA_HOME=/opt/jdk/1.7.0_21
-set.default.KARAF_HOME=/home/jbonofre/workspace/karaf/karaf/assemblies/apache-karaf/target/apache-karaf-3.0.0-SNAPSHOT
-set.default.KARAF_BASE=/home/jbonofre/workspace/karaf/karaf/assemblies/apache-karaf/target/apache-karaf-3.0.0-SNAPSHOT
-set.default.KARAF_DATA=/home/jbonofre/workspace/karaf/karaf/assemblies/apache-karaf/target/apache-karaf-3.0.0-SNAPSHOT/data
-set.default.KARAF_ETC=/home/jbonofre/workspace/karaf/karaf/assemblies/apache-karaf/target/apache-karaf-3.0.0-SNAPSHOT/etc
+set.default.KARAF_HOME=/home/jbonofre/workspace/karaf/karaf/assemblies/apache-karaf/target/apache-karaf-3.0.5-SNAPSHOT
+set.default.KARAF_BASE=/home/jbonofre/workspace/karaf/karaf/assemblies/apache-karaf/target/apache-karaf-3.0.5-SNAPSHOT
+set.default.KARAF_DATA=/home/jbonofre/workspace/karaf/karaf/assemblies/apache-karaf/target/apache-karaf-3.0.5-SNAPSHOT/data
+set.default.KARAF_ETC=/home/jbonofre/workspace/karaf/karaf/assemblies/apache-karaf/target/apache-karaf-3.0.5-SNAPSHOT/etc
# Java Application
wrapper.working.dir=%KARAF_BASE%
@@ -372,3 +386,7 @@ wrapper.ntservice.starttype=AUTO_START
# Allow the service to interact with the desktop.
wrapper.ntservice.interactive=false
{code}
+
+h3. SystemD
+
+The Karaf service wrapper also support Linux SystemD service.
http://git-wip-us.apache.org/repos/asf/karaf/blob/28f09c14/wrapper/command/src/main/java/org/apache/karaf/wrapper/commands/Install.java
----------------------------------------------------------------------
diff --git
a/wrapper/command/src/main/java/org/apache/karaf/wrapper/commands/Install.java
b/wrapper/command/src/main/java/org/apache/karaf/wrapper/commands/Install.java
index 9786deb..28b594f 100644
---
a/wrapper/command/src/main/java/org/apache/karaf/wrapper/commands/Install.java
+++
b/wrapper/command/src/main/java/org/apache/karaf/wrapper/commands/Install.java
@@ -61,6 +61,7 @@ public class Install extends AbstractAction {
String os = System.getProperty("os.name", "Unknown");
File wrapperConf = wrapperPaths[0];
File serviceFile = wrapperPaths[1];
+ File systemdFile = wrapperPaths[2];
System.out.println("");
System.out.println("Setup complete. You may wish to tweak the JVM
properties in the wrapper configuration file:");
@@ -112,7 +113,7 @@ public class Install extends AbstractAction {
if (redhatRelease.exists()) {
System.out.println("");
-
System.out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("RedHat/Fedora/CentOS
Linux system detected:").a(Ansi.Attribute.RESET).toString());
+
System.out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("RedHat/Fedora/CentOS
Linux system detected (SystemV):").a(Ansi.Attribute.RESET).toString());
System.out.println(" To install the service:");
System.out.println(" $ ln -s " + serviceFile.getPath() + "
/etc/init.d/");
System.out.println(" $ chkconfig " + serviceFile.getName()
+ " --add");
@@ -134,7 +135,7 @@ public class Install extends AbstractAction {
System.out.println(" $ rm /etc/init.d/" +
serviceFile.getPath());
} else if (debianVersion.exists()) {
System.out.println("");
-
System.out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("Ubuntu/Debian
Linux system detected:").a(Ansi.Attribute.RESET).toString());
+
System.out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("Ubuntu/Debian
Linux system detected (SystemV):").a(Ansi.Attribute.RESET).toString());
System.out.println(" To install the service:");
System.out.println(" $ ln -s " + serviceFile.getPath() + "
/etc/init.d/");
System.out.println("");
@@ -154,7 +155,7 @@ public class Install extends AbstractAction {
System.out.println(" $ rm /etc/init.d/" +
serviceFile.getName());
} else {
System.out.println("");
-
System.out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("On
Redhat/Fedora/CentOS Systems:").a(Ansi.Attribute.RESET).toString());
+
System.out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("On
Redhat/Fedora/CentOS Systems (SystemV):").a(Ansi.Attribute.RESET).toString());
System.out.println(" To install the service:");
System.out.println(" $ ln -s
"+serviceFile.getPath()+" /etc/init.d/");
System.out.println(" $ chkconfig
"+serviceFile.getName()+" --add");
@@ -176,7 +177,7 @@ public class Install extends AbstractAction {
System.out.println(" $ rm
/etc/init.d/"+serviceFile.getName());
System.out.println("");
-
System.out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("On
Ubuntu/Debian Systems:").a(Ansi.Attribute.RESET).toString());
+
System.out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("On
Ubuntu/Debian Systems (SystemV):").a(Ansi.Attribute.RESET).toString());
System.out.println(" To install the service:");
System.out.println(" $ ln -s
"+serviceFile.getPath()+" /etc/init.d/");
System.out.println("");
@@ -196,6 +197,28 @@ public class Install extends AbstractAction {
System.out.println(" $ rm
/etc/init.d/"+serviceFile.getName());
}
+ if (systemdFile != null) {
+ System.out.println("");
+
System.out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("For SystemD
compliant Linux: ").a(Ansi.Attribute.RESET).toString());
+ System.out.println(" To install the service (and enable at
system boot):");
+ System.out.println(" $ systemctl enable " +
systemdFile.getPath());
+ System.out.println("");
+ System.out.println(" To start the service:");
+ System.out.println(" $ systemctl start " + name);
+ System.out.println("");
+ System.out.println(" To stop the service:");
+ System.out.println(" $ systemctl stop " + name);
+ System.out.println("");
+ System.out.println(" To check the current service status:");
+ System.out.println(" $ systemctl status " + name);
+ System.out.println("");
+ System.out.println(" To see service activity journal:");
+ System.out.println(" $ journalctl -u " + name);
+ System.out.println("");
+ System.out.println(" To uninstall the service (and disable at
system boot):");
+ System.out.println(" $ systemctl disable " + name);
+ }
+
}
return null;
http://git-wip-us.apache.org/repos/asf/karaf/blob/28f09c14/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java
----------------------------------------------------------------------
diff --git
a/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java
b/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java
index 4b1cb2b..887073f 100644
---
a/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java
+++
b/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java
@@ -69,6 +69,7 @@ public class WrapperServiceImpl implements WrapperService {
String os = System.getProperty("os.name", "Unknown");
File serviceFile = null;
File wrapperConf = null;
+ File systemdFile = null;
if (os.startsWith("Win")) {
String arch = System.getProperty("os.arch");
if (arch.equalsIgnoreCase("amd64") ||
arch.equalsIgnoreCase("x86_64")) {
@@ -131,6 +132,10 @@ public class WrapperServiceImpl implements WrapperService {
copyFilteredResourceTo(serviceFile, "unix/karaf-service",
props, envs, includes);
chmod(serviceFile, "a+x");
+ systemdFile = new File(bin, name + ".service");
+ copyFilteredResourceTo(systemdFile, "unix/karaf.service",
props, envs, includes);
+ chmod(systemdFile, "a+x");
+
wrapperConf = new File(etc, name + "-wrapper.conf");
copyFilteredResourceTo(wrapperConf, "unix/karaf-wrapper.conf",
props, envs, includes);
@@ -147,6 +152,10 @@ public class WrapperServiceImpl implements WrapperService {
copyFilteredResourceTo(serviceFile, "unix/karaf-service",
props, envs, includes);
chmod(serviceFile, "a+x");
+ systemdFile = new File(bin, name + ".service");
+ copyFilteredResourceTo(systemdFile, "unix/karaf.service",
props, envs, includes);
+ chmod(systemdFile, "a+x");
+
wrapperConf = new File(etc, name + "-wrapper.conf");
copyFilteredResourceTo(wrapperConf, "unix/karaf-wrapper.conf",
props, envs, includes);
@@ -282,9 +291,10 @@ public class WrapperServiceImpl implements WrapperService {
createJar(new File(lib, "karaf-wrapper-main.jar"),
"org/apache/karaf/wrapper/internal/Main.class");
- File[] wrapperPaths = new File[2];
+ File[] wrapperPaths = new File[3];
wrapperPaths[0] = wrapperConf;
wrapperPaths[1] = serviceFile;
+ wrapperPaths[2] = systemdFile;
return wrapperPaths;
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/28f09c14/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-service
----------------------------------------------------------------------
diff --git
a/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-service
b/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-service
index 9f1f004..fdf37e5 100644
---
a/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-service
+++
b/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-service
@@ -17,6 +17,10 @@
# limitations under the License.
# ------------------------------------------------------------------------
+#
+# This script is an Unix SystemV script
+#
+
# If require, set the JAVA_HOME to launch the wrapper
#
#JAVA_HOME=
http://git-wip-us.apache.org/repos/asf/karaf/blob/28f09c14/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf.service
----------------------------------------------------------------------
diff --git
a/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf.service
b/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf.service
new file mode 100644
index 0000000..68d239e
--- /dev/null
+++
b/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf.service
@@ -0,0 +1,33 @@
+# ------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ------------------------------------------------------------------------
+
+#
+# This script is an Unix SystemD script
+#
+[Unit]
+Description=${displayName}
+
+[Service]
+Type=forking
+PIDFile=${karaf.data}/${name}.pid
+ExecStart=${karaf.base}/bin/${name}-service start
+ExecReload=${karaf.base}/bin/${name}-service restart
+ExecStop=${karaf.base}/bin/${name}-service stop
+
+[Install]
+Alias=${name}
+WantedBy=default.target
\ No newline at end of file