Fixes ACTIVEMQ6-99: Support installing as a windows service
This commit is contained in:
parent
3b82dc52ed
commit
e12388ff44
|
@ -61,6 +61,14 @@
|
|||
<groupId>io.airlift</groupId>
|
||||
<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>
|
||||
|
@ -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>
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
write("etc/activemq.profile.cmd", filters, false);
|
||||
|
||||
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/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));
|
||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue