Skip to content
This repository has been archived by the owner on Jan 21, 2023. It is now read-only.

Commit

Permalink
Merge branch release/1.1.0 into master
Browse files Browse the repository at this point in the history
Distribute the executable fat-jar (smaller zip files)
Include install/uninstall/startup/shutdown helper batch commands
Fix sample application to be executible
  • Loading branch information
Paul Campbell committed Apr 21, 2016
2 parents 37ef414 + 94752bc commit 27ff061
Show file tree
Hide file tree
Showing 18 changed files with 220 additions and 176 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGELOG
=========

1.1.0
------

* Distribute the executable fat-jar (smaller zip files)
* Include install/uninstall/startup/shutdown helper batch commands
* Fix sample application to be executible

1.0.1
------

Expand Down
79 changes: 55 additions & 24 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,85 @@ The `windows` distribution uses https://github.com/kohsuke/winsw[`winsw`].

WARNING: You need to install the `.NET` framework on the target machine first.

## Sample applications
## Installing and Running Services

To install the sample application as a service, extract the distribution somewhere and open a shell with
administrative rights in that directory. Then invoke the following command
To install the application as a service, extract the distribution zip somewhere and open a shell with
administrative rights in that directory.

[source,bash]
.Install Service
----
$ spring-boot-daemon-sample.exe install
C:\dir> install.bat
----

[NOTE]
====
`spring-boot-daemon-sample` is the identifier of the service. You can control that via Maven properties
in the `spring-boot-daemon-sample` project.
====

Once the service has been installed, you can start it the usual way, that is:

[source,bash]
.Start Service
----
C:\dir> startup.bat
----

.Stop Service
----
C:\dir> shutdown.bat
----

.Run Application from Command line
----
C:\dir> run.bat
----

.View Service Status
----
C:\dir> status.bat
----

Note: A result of `NonExistent` means the service is not installed.

.Uninstall Service
----
$ net start spring-boot-daemon-sample
C:\dir> shutdown.bat
C:\dir> uninstall.bat
----

## Logs

The logs are available in the `logs` directory of the distribution.

## Usage
## Usage in your application

Or, **How to convert your application into a Windows Service**.

To enable running your own Spring Boot applications as a Windows Service:

1. add `net.kemitix:spring-boot-daemon-integration` as a dependency
2. copy, unaltered, the `assembly` and `dist` directories from `spring-boot-daemon-sample/src/main` into your own application
sources
3. add the `project/build/plugins` section from `spring-boot-daemon-sample/pom.xml` to your own `pom.xml`, including the
`spring-boot-maven-plugin` (needs layout=ZIP)
4. add the following properties to your `pom.xml`, updating the values to suite
`spring-boot-maven-plugin` (needs layout=ZIP), which should be first among these plugins
4. add the following properties to your `pom.xml`, updating the values to suit:
[source,xml]
----
<properties>
<spring-boot.version>1.3.3.RELEASE</spring-boot.version>
<start-class>net.nicoll.SampleApplication</start-class> <!--1-->
<winsw.version>1.18</winsw.version>
<maven-dependency-plugin.version>2.10</maven-dependency-plugin.version>
<maven-resources-plugin.verion>2.7</maven-resources-plugin.verion>
<maven-assembly-plugin.version>2.6</maven-assembly-plugin.version>
<dist.dir>${project.build.directory}/dist</dist.dir>
<dist.project.id>${project.artifactId}</dist.project.id>
<dist.project.version>${project.version}</dist.project.version>
<dist.project.name>Sample Spring Boot App</dist.project.name>
<dist.project.description>
Demonstrate how to integrate a Spring Boot app as a Windows Service
</dist.project.description>
<dist.start.class>net.nicoll.SampleApplication</dist.start.class>
<dist.jmx.port>50201</dist.jmx.port>
<dist.service.name>${project.artifactId}</dist.service.name>
<dist.service.display.name>Sample Spring Boot App</dist.service.display.name> <!--2-->
<dist.service.description>
Demonstrate how to integrate a Spring Boot app as a Windows Service <!--3-->
</dist.service.description>
<dist.jar>lib\${project.artifactId}-${project.version}.jar</dist.jar>
<dist.start.class>${start-class}</dist.start.class>
<dist.jmx.port>50201</dist.jmx.port> <!--4-->
</properties>
----
<1> Your Spring Boot application class
<2> The name that shows in the Windows Services Control Panel
<3> The longer description that shows in the Windows Services Control Panel
<4> The JMX Port on the machine that will be assigned to the server, must not conflict with another usage and is
required to be able to shutdown the service
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<version>1.11.0</version>
</parent>
<artifactId>spring-boot-daemon</artifactId>
<version>1.0.1</version>
<version>1.1.0</version>
<packaging>pom</packaging>
<name>Spring Boot Daemon</name>
<description>
Expand Down
2 changes: 1 addition & 1 deletion spring-boot-daemon-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>net.kemitix</groupId>
<artifactId>spring-boot-daemon</artifactId>
<version>1.0.1</version>
<version>1.1.0</version>
</parent>
<artifactId>spring-boot-daemon-integration</artifactId>
<packaging>jar</packaging>
Expand Down
60 changes: 34 additions & 26 deletions spring-boot-daemon-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,27 @@
<parent>
<groupId>net.kemitix</groupId>
<artifactId>spring-boot-daemon</artifactId>
<version>1.0.1</version>
<version>1.1.0</version>
</parent>
<artifactId>spring-boot-daemon-sample</artifactId>
<packaging>jar</packaging>
<name>Spring Boot Daemon :: Sample</name>

<properties>
<spring-boot.version>1.3.3.RELEASE</spring-boot.version>
<start-class>net.nicoll.SampleApplication</start-class>
<winsw.version>1.18</winsw.version>
<maven-dependency-plugin.version>2.10</maven-dependency-plugin.version>
<maven-resources-plugin.verion>2.7</maven-resources-plugin.verion>
<maven-assembly-plugin.version>2.6</maven-assembly-plugin.version>
<dist.dir>${project.build.directory}/dist</dist.dir>
<dist.project.id>${project.artifactId}</dist.project.id>
<dist.project.version>${project.version}</dist.project.version>
<dist.project.name>Sample Spring Boot App</dist.project.name>
<dist.project.description>
<dist.service.name>${project.artifactId}</dist.service.name>
<dist.service.display.name>Sample Spring Boot App</dist.service.display.name>
<dist.service.description>
Demonstrate how to integrate a Spring Boot app as a Windows Service
</dist.project.description>
<dist.start.class>net.nicoll.SampleApplication</dist.start.class>
</dist.service.description>
<dist.jar>lib\${project.artifactId}-${project.version}.jar</dist.jar>
<dist.start.class>${start-class}</dist.start.class>
<dist.jmx.port>50201</dist.jmx.port>
</properties>

Expand All @@ -43,10 +48,28 @@

<build>
<plugins>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>${start-class}</mainClass>
<layout>ZIP</layout>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<version>${maven-dependency-plugin.version}</version>
<executions>
<execution>
<id>copy</id>
Expand All @@ -72,7 +95,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<version>${maven-resources-plugin.verion}</version>
<executions>
<execution>
<id>copy-resources</id>
Expand All @@ -96,7 +119,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/windows.xml</descriptor>
Expand All @@ -112,22 +135,7 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>${dist.start.class}</mainClass>
<layout>ZIP</layout>
</configuration>
</plugin>

</plugins>
</build>

Expand Down
115 changes: 74 additions & 41 deletions spring-boot-daemon-sample/src/main/assembly/windows.xml
Original file line number Diff line number Diff line change
@@ -1,47 +1,80 @@
<?xml version="1.0"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>windows</id>
<assembly xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>windows</id>

<formats>
<format>zip</format>
</formats>
<formats>
<format>zip</format>
</formats>

<dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<outputDirectory>lib</outputDirectory>
</dependencySet>
</dependencySets>
<dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<outputDirectory>lib</outputDirectory>
<useTransitiveDependencies>false</useTransitiveDependencies>
<useStrictFiltering>true</useStrictFiltering>
<includes>
<include>${project.groupId}:${project.artifactId}</include>
</includes>
</dependencySet>
</dependencySets>

<!-- Workaround to create logs directory -->
<fileSets>
<fileSet>
<directory>${dist.dir}</directory>
<outputDirectory>logs</outputDirectory>
<excludes>
<exclude>*/**</exclude>
</excludes>
</fileSet>
</fileSets>
<!-- Workaround to create logs directory -->
<fileSets>
<fileSet>
<directory>${dist.dir}</directory>
<outputDirectory>logs</outputDirectory>
<excludes>
<exclude>*/**</exclude>
</excludes>
</fileSet>
</fileSets>

<files>
<file>
<source>${dist.dir}/service.exe</source>
<outputDirectory/>
<destName>${dist.project.id}.exe</destName>
</file>
<file>
<source>${dist.dir}/service.xml</source>
<outputDirectory/>
<destName>${dist.project.id}.xml</destName>
</file>
<file>
<source>${dist.dir}/service.exe.config</source>
<outputDirectory/>
<destName>${dist.project.id}.exe.config</destName>
</file>
<files>
<file>
<source>${dist.dir}/service.exe</source>
<outputDirectory/>
<destName>${dist.service.name}.exe</destName>
</file>
<file>
<source>${dist.dir}/service.xml</source>
<outputDirectory/>
<destName>${dist.service.name}.xml</destName>
</file>
<file>
<source>${dist.dir}/service.exe.config</source>
<outputDirectory/>
<destName>${dist.service.name}.exe.config</destName>
</file>
<file>
<source>${dist.dir}/run.bat</source>
<outputDirectory/>
</file>
<file>
<source>${dist.dir}/stop.bat</source>
<outputDirectory/>
</file>
<file>
<source>${dist.dir}/status.bat</source>
<outputDirectory/>
</file>
<file>
<source>${dist.dir}/install.bat</source>
<outputDirectory/>
</file>
<file>
<source>${dist.dir}/startup.bat</source>
<outputDirectory/>
</file>
<file>
<source>${dist.dir}/shutdown.bat</source>
<outputDirectory/>
</file>
<file>
<source>${dist.dir}/uninstall.bat</source>
<outputDirectory/>
</file>

</files>
</assembly>
</files>
</assembly>
14 changes: 0 additions & 14 deletions spring-boot-daemon-sample/src/main/dist/bin/run.sh

This file was deleted.

Loading

0 comments on commit 27ff061

Please sign in to comment.