You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by an...@apache.org on 2013/10/31 00:20:46 UTC

svn commit: r1537340 - in /karaf/trunk: manual/src/main/webapp/users-guide/ service/guard/ wrapper/command/src/main/java/org/apache/karaf/wrapper/commands/ wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/ wrapper/core/src/main/resources/or...

Author: anierbeck
Date: Wed Oct 30 23:20:46 2013
New Revision: 1537340

URL: http://svn.apache.org/r1537340
Log:
[KARAF-2542] - Enhance documentation and wrapper for running Karaf as service with Mac OS X

Added:
    karaf/trunk/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/macosx/org.apache.karaf.KARAF.plist
Modified:
    karaf/trunk/manual/src/main/webapp/users-guide/wrapper.conf
    karaf/trunk/service/guard/   (props changed)
    karaf/trunk/wrapper/command/src/main/java/org/apache/karaf/wrapper/commands/Install.java
    karaf/trunk/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java

Modified: karaf/trunk/manual/src/main/webapp/users-guide/wrapper.conf
URL: http://svn.apache.org/viewvc/karaf/trunk/manual/src/main/webapp/users-guide/wrapper.conf?rev=1537340&r1=1537339&r2=1537340&view=diff
==============================================================================
--- karaf/trunk/manual/src/main/webapp/users-guide/wrapper.conf (original)
+++ karaf/trunk/manual/src/main/webapp/users-guide/wrapper.conf Wed Oct 30 23:20:46 2013
@@ -120,6 +120,38 @@ On Ubuntu/Debian Systems:
     $ rm /etc/init.d/KARAF-service
 {code}
 
+On MacOS you can install the service for an user or for the system.
+
+to add bin/org.apache.karaf.KARAF as user service move this file into ~/Library/LaunchAgents/
+{code}
+> mv bin/org.apache.karaf.KARAF.plist ~/Library/LaunchAgents/
+{code}
+
+to add org.apache.karaf.KARAF as system service move this into /Library/LaunchDaemons
+{code}
+> sudo mv bin/org.apache.karaf.KARAF.plist /Library/LaunchDaemons/
+{code}
+change owner and rights
+{code}
+> sudo chown root:wheel /Library/LaunchDaemons/org.apache.karaf.KARAF.plist
+> sudo chmod u=rw,g=r,o=r /Library/LaunchDaemons/org.apache.karaf.KARAF.plist
+{code}
+
+test your service
+{code}
+> launchctl load ~/Library/LaunchAgents/org.apache.karaf.KARAF.plist
+> launchctl start org.apache.karaf.KARAF
+> launchctl stop org.apache.karaf.KARAF
+{code}
+
+after restart your session or system
+you can use launchctl command to start and stop your service
+
+for removing the service call
+{code}
+> launchctl remove org.apache.karaf.KARAF
+{code}
+
 h2. Configuration Hints
 
 By default, the wrapper sets the JAVA_HOME in etc/karaf-wrapper.conf file. However, the bin/karaf-service script uses java. If required, you have to define the JAVA_HOME in this bin/karaf-service script.

Propchange: karaf/trunk/service/guard/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Oct 30 23:20:46 2013
@@ -3,3 +3,5 @@
 .project
 
 .classpath
+
+target

Modified: karaf/trunk/wrapper/command/src/main/java/org/apache/karaf/wrapper/commands/Install.java
URL: http://svn.apache.org/viewvc/karaf/trunk/wrapper/command/src/main/java/org/apache/karaf/wrapper/commands/Install.java?rev=1537340&r1=1537339&r2=1537340&view=diff
==============================================================================
--- karaf/trunk/wrapper/command/src/main/java/org/apache/karaf/wrapper/commands/Install.java (original)
+++ karaf/trunk/wrapper/command/src/main/java/org/apache/karaf/wrapper/commands/Install.java Wed Oct 30 23:20:46 2013
@@ -31,25 +31,25 @@ import org.fusesource.jansi.Ansi;
 @Command(scope = "wrapper", name = "install", description = "Install the container as a system service in the OS.")
 public class Install extends AbstractAction {
 
-    @Option(name = "-n", aliases = {"--name"}, description = "The service name that will be used when installing the service. (Default: karaf)", required = false, multiValued = false)
-    private String name = "karaf";
+	@Option(name = "-n", aliases = { "--name" }, description = "The service name that will be used when installing the service. (Default: karaf)", required = false, multiValued = false)
+	private String name = "karaf";
 
-    @Option(name = "-d", aliases = {"--display"}, description = "The display name of the service.", required = false, multiValued = false)
-    private String displayName;
+	@Option(name = "-d", aliases = { "--display" }, description = "The display name of the service.", required = false, multiValued = false)
+	private String displayName;
 
-    @Option(name = "-D", aliases = {"--description"}, description = "The description of the service.", required = false, multiValued = false)
-    private String description = "";
+	@Option(name = "-D", aliases = { "--description" }, description = "The description of the service.", required = false, multiValued = false)
+	private String description = "";
 
-    @Option(name = "-s", aliases = {"--start-type"}, description = "Mode in which the service is installed. AUTO_START or DEMAND_START (Default: AUTO_START)", required = false, multiValued = false)
-    private String startType = "AUTO_START";
+	@Option(name = "-s", aliases = { "--start-type" }, description = "Mode in which the service is installed. AUTO_START or DEMAND_START (Default: AUTO_START)", required = false, multiValued = false)
+	private String startType = "AUTO_START";
 
-    private WrapperService wrapperService = new WrapperServiceImpl();
+	private WrapperService wrapperService = new WrapperServiceImpl();
 
-    public void setWrapperService(WrapperService wrapperService) {
-        this.wrapperService = wrapperService;
-    }
+	public void setWrapperService(WrapperService wrapperService) {
+		this.wrapperService = wrapperService;
+	}
 
-    protected Object doExecute() throws Exception {
+	protected Object doExecute() throws Exception {
         File[] wrapperPaths = wrapperService.install(name, displayName, description, startType);
 
         String os = System.getProperty("os.name", "Unknown");
@@ -77,16 +77,25 @@ public class Install extends AbstractAct
             System.out.println("");
         } else if (os.startsWith("Mac OS X")) {
             System.out.println("");
-            System.out.println("At this time it is not known how to get this service to start when the machine is rebooted.");
-            System.out.println("If you know how to install the following service script so that it gets started");
-            System.out.println("when OS X starts, please email dev@felix.apache.org and let us know how so");
-            System.out.println("we can update this message.");
-            System.out.println(" ");
-            System.out.println("  To start the service:");
-            System.out.println("    $ " + serviceFile.getPath() + " start");
+            System.out.println("to add bin/org.apache.karaf.KARAF as user service move this file into ~/Library/LaunchAgents/");  
+            System.out.println("> mv bin/org.apache.karaf.KARAF.plist ~/Library/LaunchAgents/");
             System.out.println("");
-            System.out.println("  To stop the service:");
-            System.out.println("    $ " + serviceFile.getPath() + " stop");
+            System.out.println("to add org.apache.karaf.KARAF as system service move this into /Library/LaunchDaemons");  
+            System.out.println("> sudo mv bin/org.apache.karaf.KARAF.plist /Library/LaunchDaemons/");  
+            System.out.println("change owner and rights");  
+            System.out.println("> sudo chown root:wheel /Library/LaunchDaemons/org.apache.karaf.KARAF.plist");  
+            System.out.println("> sudo chmod u=rw,g=r,o=r /Library/LaunchDaemons/org.apache.karaf.KARAF.plist");  
+            System.out.println(""); 
+            System.out.println("test your service");  
+            System.out.println("> launchctl load ~/Library/LaunchAgents/org.apache.karaf.KARAF.plist");  
+            System.out.println("> launchctl start org.apache.karaf.KARAF");  
+            System.out.println("> launchctl stop org.apache.karaf.KARAF");  
+            System.out.println("");  
+            System.out.println("after restart your session or system");  
+            System.out.println("you can use launchctl command to start and stop your service");  
+            System.out.println("");  
+            System.out.println("for removing the service call");  
+            System.out.println("> launchctl remove org.apache.karaf.KARAF");  
             System.out.println("");
         } else if (os.startsWith("Linux")) {
 
@@ -181,5 +190,4 @@ public class Install extends AbstractAct
 
         return null;
     }
-
 }

Modified: karaf/trunk/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java
URL: http://svn.apache.org/viewvc/karaf/trunk/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java?rev=1537340&r1=1537339&r2=1537340&view=diff
==============================================================================
--- karaf/trunk/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java (original)
+++ karaf/trunk/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/WrapperServiceImpl.java Wed Oct 30 23:20:46 2013
@@ -106,6 +106,9 @@ public class WrapperServiceImpl implemen
             wrapperConf = new File(etc, name + "-wrapper.conf");
             copyFilteredResourceTo(wrapperConf, "unix/karaf-wrapper.conf", props);
 
+            File plistConf = new File(bin, "org.apache.karaf."+ name + ".plist");
+            copyFilteredResourceTo(plistConf, "macosx/org.apache.karaf.KARAF.plist", props);
+            
             mkdir(lib);
 
             copyResourceTo(new File(lib, "libwrapper.jnilib"), "macosx/libwrapper.jnilib", false);

Added: karaf/trunk/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/macosx/org.apache.karaf.KARAF.plist
URL: http://svn.apache.org/viewvc/karaf/trunk/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/macosx/org.apache.karaf.KARAF.plist?rev=1537340&view=auto
==============================================================================
--- karaf/trunk/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/macosx/org.apache.karaf.KARAF.plist (added)
+++ karaf/trunk/wrapper/core/src/main/resources/org/apache/karaf/wrapper/internal/macosx/org.apache.karaf.KARAF.plist Wed Oct 30 23:20:46 2013
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>ProcessType</key>
+	<string>Background</string>
+	<key>KeepAlive</key>
+	<false/>
+	<key>Label</key>
+	<string>org.apache.karaf.KARAF</string>
+	<key>ProgramArguments</key>
+	<array>
+		<!-- path to your KARAF-service wrapper -->
+		<string>${karaf.home}/bin/${name}-service</string>
+		<string>console</string>
+	</array>
+	<key>RunAtLoad</key>
+	<true/>
+</dict>
+</plist>
\ No newline at end of file