activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-6 git commit: Fixes ACTIVEMQ6-99: Support installing as a windows service
Date Mon, 20 Apr 2015 19:37:16 GMT
Repository: activemq-6
Updated Branches:
  refs/heads/master 3b82dc52e -> db5fd9ddd


Fixes ACTIVEMQ6-99: Support installing as a windows service

Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/e12388ff
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/e12388ff
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/e12388ff

Branch: refs/heads/master
Commit: e12388ff44c4f359e3cc4a7a49b1e33d663a47c5
Parents: 3b82dc5
Author: Hiram Chirino <hiram@hiramchirino.com>
Authored: Thu Apr 16 23:00:29 2015 -0400
Committer: Hiram Chirino <hiram@hiramchirino.com>
Committed: Thu Apr 16 23:00:29 2015 -0400

----------------------------------------------------------------------
 activemq-bootstrap/pom.xml                      | 38 +++++++++++
 .../apache/activemq/cli/commands/Create.java    | 69 +++++++++++---------
 .../cli/commands/bin/activemq-service.xml       | 59 +++++++++++++++++
 3 files changed, 135 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e12388ff/activemq-bootstrap/pom.xml
----------------------------------------------------------------------
diff --git a/activemq-bootstrap/pom.xml b/activemq-bootstrap/pom.xml
index 6aecaac..85687e7 100644
--- a/activemq-bootstrap/pom.xml
+++ b/activemq-bootstrap/pom.xml
@@ -62,6 +62,14 @@
          <artifactId>airline</artifactId>
       </dependency>
       <dependency>
+        <groupId>com.sun.winsw</groupId>
+        <artifactId>winsw</artifactId>
+        <version>1.9</version>
+        <classifier>bin</classifier>
+        <type>exe</type>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <scope>test</scope>
@@ -102,6 +110,36 @@
          </includes>
        </resource>
      </resources>
+
+     <plugins>
+       <plugin>
+         <groupId>org.apache.maven.plugins</groupId>
+         <artifactId>maven-dependency-plugin</artifactId>
+         <version>2.2</version>
+         <executions>
+           <execution>
+             <id>unpack</id>
+             <phase>process-resources</phase>
+             <goals>
+               <goal>copy</goal>
+             </goals>
+             <configuration>
+               <artifactItems>
+                 <artifactItem>
+                   <groupId>com.sun.winsw</groupId>
+                   <artifactId>winsw</artifactId>
+                   <version>1.9</version>
+                   <classifier>bin</classifier>
+                   <type>exe</type>
+                   <outputDirectory>${basedir}/target/classes/org/apache/activemq/cli/commands/bin</outputDirectory>
+                   <destFileName>activemq-service.exe</destFileName>
+                 </artifactItem>
+               </artifactItems>
+             </configuration>
+           </execution>
+         </executions>
+       </plugin>
+     </plugins>
    </build>
 
 

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e12388ff/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Create.java
----------------------------------------------------------------------
diff --git a/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Create.java
b/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Create.java
index 1a30a84..49f7164 100644
--- a/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Create.java
+++ b/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Create.java
@@ -97,24 +97,7 @@ public class Create implements Action
          host = directory.getName();
       }
 
-      new File(directory, "bin").mkdirs();
-      new File(directory, "etc").mkdirs();
-      new File(directory, "log").mkdirs();
-      new File(directory, "tmp").mkdirs();
-      new File(directory, "data").mkdirs();
-
-      write("bin/activemq", null, true);
-      makeExec("bin/activemq");
-
-      write("bin/activemq.cmd", null, false);
-      write("bin/activemq-service", null, true);
-      makeExec("bin/activemq-service");
-
-      write("etc/logging.properties", null, false);
-      write("etc/bootstrap.xml", null, false);
-
       HashMap<String, String> filters = new HashMap<String, String>();
-
       String replicatedSettings = "";
       if (replicated)
       {
@@ -149,15 +132,37 @@ public class Create implements Action
       filters.put("${activemq.instance}", path(directory, false));
       filters.put("${java.home}", path(System.getProperty("java.home"), false));
 
-      write("etc/activemq.profile", filters, true);
-      makeExec("etc/activemq.profile");
+      new File(directory, "bin").mkdirs();
+      new File(directory, "etc").mkdirs();
+      new File(directory, "log").mkdirs();
+      new File(directory, "tmp").mkdirs();
+      new File(directory, "data").mkdirs();
+
+
+      if (IS_WINDOWS)
+      {
+         write("bin/activemq.cmd", null, false);
+         write("bin/activemq-service.exe");
+         write("bin/activemq-service.xml", filters, false);
+         write("etc/activemq.profile.cmd", filters, false);
+      }
+
+      if (!IS_WINDOWS || IS_CYGWIN)
+      {
+         write("bin/activemq", null, true);
+         makeExec("bin/activemq");
+         write("bin/activemq-service", null, true);
+         makeExec("bin/activemq-service");
+         write("etc/activemq.profile", filters, true);
+         makeExec("etc/activemq.profile");
+      }
 
-      write("etc/activemq.profile.cmd", filters, false);
+      write("etc/logging.properties", null, false);
+      write("etc/bootstrap.xml", null, false);
       write("etc/activemq-configuration.xml", filters, false);
       write("etc/activemq-roles.properties", null, false);
       write("etc/activemq-users.properties", null, false);
 
-
       context.out.println("");
       context.out.println("You can now start the broker by executing:  ");
       context.out.println("");
@@ -189,15 +194,16 @@ public class Create implements Action
          }
 
       }
-//      if ( IS_WINDOWS ) {
-//
-//        context.out.println("Or you can setup the broker as Windows service and run it
in the background:");
-//        context.out.println("");
-//        context.out.println(String.format("   \"%s\" install", path(service,true)));
-//        context.out.println(String.format("   \"%s\" start", path(service, true)));
-//        context.out.println("");
-//
-//      }
+      if (IS_WINDOWS)
+      {
+
+         context.out.println("Or you can setup the broker as Windows service and run it in
the background:");
+         context.out.println("");
+         context.out.println(String.format("   \"%s\" install", path(service, true)));
+         context.out.println(String.format("   \"%s\" start", path(service, true)));
+         context.out.println("");
+
+      }
 
       return null;
    }
@@ -282,8 +288,9 @@ public class Create implements Action
       return new String(out.toByteArray(), "UTF-8");
    }
 
-   private void write(String source, File target) throws IOException
+   private void write(String source) throws IOException
    {
+      File target = new File(directory, source);
       if (target.exists() && !force)
       {
          throw new RuntimeException(String.format("The file '%s' already exists.  Use --force
to overwrite.", target));

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e12388ff/activemq-bootstrap/src/main/resources/org/apache/activemq/cli/commands/bin/activemq-service.xml
----------------------------------------------------------------------
diff --git a/activemq-bootstrap/src/main/resources/org/apache/activemq/cli/commands/bin/activemq-service.xml
b/activemq-bootstrap/src/main/resources/org/apache/activemq/cli/commands/bin/activemq-service.xml
new file mode 100644
index 0000000..fa815aa
--- /dev/null
+++ b/activemq-bootstrap/src/main/resources/org/apache/activemq/cli/commands/bin/activemq-service.xml
@@ -0,0 +1,59 @@
+<!--
+
+    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.
+
+-->
+
+<service>
+   <id>activemq-${host}</id>
+   <name>ActiveMQ: ${host}</name>
+   <description>Apache ActiveMQ is a reliable messaging broker</description>
+
+   <logpath>${activemq.instance}\log</logpath>
+   <logmode>roll</logmode>
+
+   <executable>"${java.home}\bin\java.exe"</executable>
+   <argument>-XX:+UseParallelGC</argument>
+   <argument>-XX:+AggressiveOpts</argument>
+   <argument>-XX:+UseFastAccessorMethods</argument>
+   <argument>-Xms512M</argument>
+   <argument>-Xmx1024M</argument>
+
+   <!-- Cluster Properties: Used to pass arguments to ActiveMQ which can be referenced
in activemq-configuration.xml
+   <argument>-Dactivemq.remoting.default.port=61617</argument>
+   <argument>-Dactivemq.remoting.amqp.port=5673</argument>
+   <argument>-Dactivemq.remoting.stomp.port=61614</argument>
+   <argument>-Dactivemq.remoting.hornetq.port=5446</argument>
+   -->
+
+   <argument>-classpath</argument>
+   <argument>"${activemq.home}\lib\activemq-boot.jar"</argument>
+   <argument>"-Dactivemq.home=${activemq.home}"</argument>
+   <argument>"-Dactivemq.instance=${activemq.instance}"</argument>
+   <argument>"-Ddata.dir=${activemq.instance}/data"</argument>
+   <argument>-Djava.util.logging.manager=org.jboss.logmanager.LogManager</argument>
+   <argument>"-Dlogging.configuration=file:${activemq.instance}\etc\logging.properties"</argument>
+
+
+   <!-- Debug args: Uncomment to enable debug
+   <argument>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005</argument>
+   -->
+
+   <argument>org.apache.activemq.boot.ActiveMQ</argument>
+
+   <argument>run</argument>
+
+</service>
\ No newline at end of file


Mime
View raw message