You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2015/09/15 11:13:50 UTC
karaf git commit: [KARAF-3858] Add support of systemd in wrapper
Repository: karaf
Updated Branches:
refs/heads/master 60c1aee17 -> 91678ff51
[KARAF-3858] Add support of systemd in wrapper
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/91678ff5
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/91678ff5
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/91678ff5
Branch: refs/heads/master
Commit: 91678ff512523e7b0beca2892f131bc44092116c
Parents: 60c1aee
Author: Jean-Baptiste Onofré <jb...@apache.org>
Authored: Tue Sep 15 11:13:22 2015 +0200
Committer: Jean-Baptiste Onofré <jb...@apache.org>
Committed: Tue Sep 15 11:13:22 2015 +0200
----------------------------------------------------------------------
manual/src/main/webapp/users-guide/wrapper.conf | 20 +++++++++++-
.../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, 94 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/91678ff5/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 e7497bd..5656fb4 100644
--- a/manual/src/main/webapp/users-guide/wrapper.conf
+++ b/manual/src/main/webapp/users-guide/wrapper.conf
@@ -143,13 +143,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-4.0.0/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-4.0.2/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).
@@ -160,6 +168,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}
@@ -373,3 +387,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.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf/blob/91678ff5/wrapper/src/main/java/org/apache/karaf/wrapper/commands/Install.java
----------------------------------------------------------------------
diff --git a/wrapper/src/main/java/org/apache/karaf/wrapper/commands/Install.java b/wrapper/src/main/java/org/apache/karaf/wrapper/commands/Install.java
index 39771d6..86f7665 100644
--- a/wrapper/src/main/java/org/apache/karaf/wrapper/commands/Install.java
+++ b/wrapper/src/main/java/org/apache/karaf/wrapper/commands/Install.java
@@ -63,6 +63,7 @@ public class Install implements Action {
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:");
@@ -114,7 +115,7 @@ public class Install implements Action {
if (redhatRelease.exists()) {
System.out.println("");
- System.out.println(INTENSITY_BOLD + "RedHat/Fedora/CentOS Linux system detected:" + INTENSITY_NORMAL);
+ System.out.println(INTENSITY_BOLD + "RedHat/Fedora/CentOS Linux system detected (SystemV):" + INTENSITY_NORMAL);
System.out.println(" To install the service:");
System.out.println(" $ ln -s " + serviceFile.getPath() + " /etc/init.d/");
System.out.println(" $ chkconfig " + serviceFile.getName() + " --add");
@@ -136,7 +137,7 @@ public class Install implements Action {
System.out.println(" $ rm /etc/init.d/" + serviceFile.getPath());
} else if (debianVersion.exists()) {
System.out.println("");
- System.out.println(INTENSITY_BOLD + "Ubuntu/Debian Linux system detected:" + INTENSITY_NORMAL);
+ System.out.println(INTENSITY_BOLD + "Ubuntu/Debian Linux system detected (SystemV):" + INTENSITY_NORMAL);
System.out.println(" To install the service:");
System.out.println(" $ ln -s " + serviceFile.getPath() + " /etc/init.d/");
System.out.println("");
@@ -156,7 +157,7 @@ public class Install implements Action {
System.out.println(" $ rm /etc/init.d/" + serviceFile.getName());
} else {
System.out.println("");
- System.out.println(INTENSITY_BOLD + "On Redhat/Fedora/CentOS Systems:" + INTENSITY_NORMAL);
+ System.out.println(INTENSITY_BOLD + "On Redhat/Fedora/CentOS Systems (SystemV):" + INTENSITY_NORMAL);
System.out.println(" To install the service:");
System.out.println(" $ ln -s "+serviceFile.getPath()+" /etc/init.d/");
System.out.println(" $ chkconfig "+serviceFile.getName()+" --add");
@@ -178,7 +179,7 @@ public class Install implements Action {
System.out.println(" $ rm /etc/init.d/"+serviceFile.getName());
System.out.println("");
- System.out.println(INTENSITY_BOLD + "On Ubuntu/Debian Systems:" + INTENSITY_NORMAL);
+ System.out.println(INTENSITY_BOLD + "On Ubuntu/Debian Systems (SystemV):" + INTENSITY_NORMAL);
System.out.println(" To install the service:");
System.out.println(" $ ln -s "+serviceFile.getPath()+" /etc/init.d/");
System.out.println("");
@@ -198,6 +199,28 @@ public class Install implements Action {
System.out.println(" $ rm /etc/init.d/"+serviceFile.getName());
}
+ if (systemdFile != null) {
+ System.out.println("");
+ System.out.println(INTENSITY_BOLD + "For SystemD compliant Linux: " + INTENSITY_NORMAL);
+ 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/91678ff5/wrapper/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java
----------------------------------------------------------------------
diff --git a/wrapper/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java b/wrapper/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java
index 1d8ed60..cb9e4fe 100644
--- a/wrapper/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java
+++ b/wrapper/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;
File wrapperConf;
+ 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/service/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/91678ff5/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-service
----------------------------------------------------------------------
diff --git a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-service b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-service
index 9f1f004..fdf37e5 100644
--- a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-service
+++ b/wrapper/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/91678ff5/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf.service
----------------------------------------------------------------------
diff --git a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf.service b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf.service
new file mode 100644
index 0000000..68d239e
--- /dev/null
+++ b/wrapper/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