Skip to content

deployment

James Moger edited this page Jan 28, 2016 · 9 revisions

Deployment

Fathom does not supply a deployment solution. It does, however, recommend two available solutions.

  • Stork, for more traditional distribution and foolproof Linux/Windows/OSX service integration
  • Capsule, for more modern distribution

Stork

Stork will generate a universal .tar.gz bundle of your application with shell scripts & batch files that will correctly launch your application and optionally install/remove an operating system service for your application.

Layout

YourApp
├── pom.xml
└── src
    └── main
        └── launchers
            └── fathom.yml

Configuration

pom.xml

<build>
  <plugins>
    <plugin>
      <groupId>com.fizzed</groupId>
      <artifactId>fizzed-stork-maven-plugin</artifactId>
      <version>1.2.2</version>
      <executions>
        <execution>
          <id>generate-stork-launchers</id>
          <goals>
            <goal>generate</goal>
          </goals>
        </execution>
        <execution>
          <id>generate-stork-assembly</id>
          <goals>
            <goal>assembly</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

src/main/launchers/fathom.yml

#
# Stork Packaging
# https://github.com/fizzed/java-stork
#
name: "fathom-fit" # $SERVICE
domain: "com.gitblit.fathom"
display_name: "fathom-fit"
short_description: "Fathom Integration Test"
type: DAEMON
main_class: "fathom.Boot"
platforms: [ WINDOWS, LINUX, MAC_OSX ]
min_java_version: "1.8"
min_java_memory: 1024
symlink_java: true

Quick Service Installation (Linux)

These instructions assume you have root permissions.

  1. Unpack the Stork tarball to a directory that we'll call $APPDIR
  2. cp $APPDIR/share/init.d/$SERVICE.init /etc/init.d/$SERVICE where $SERVICE is the name of your service as defined in your launcher definition.
  3. update-rc.d $SERVICE defaults

Declaring Environment Variables (Linux)

The Stork service scripts will set environment variables defined in /etc/default/$SERVICE, where $SERVICE is the name of your service as defined in your launcher definition.

echo "MYAPP_HOME=/opt/myapp-data" > /etc/default/$SERVICE
Basic Service Administration (Linux)
service $SERVICE start
service $SERVICE stop

Capsule

Capsule describes itself as dead-simple packaging and deployment for JVM applications.

Capsule generates either a fat-jar, similar to Maven's Shade plugin or Gradle's Shadow plugin, or a thin-jar that automatically downloads dependencies on first execution.

In a typical Fathom application it's very easy to generate a 25MB+ distribution. This makes The thin-jar build particularly appealing since it is likely to be under a few MB.

Configuration

pom.xml

<build>
  <plugins>
    <plugin>
      <groupId>com.github.chrischristo</groupId>
      <artifactId>capsule-maven-plugin</artifactId>
      <version>0.10.3</version>
      <executions>
        <execution>
          <goals>
            <goal>build</goal>
          </goals>
          <configuration>
            <appClass>fathom.Boot</appClass>
            <chmod>true</chmod>
            <trampoline>true</trampoline>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

Using Environment Variables in your Microservice

Environment variables may be used by your microservice in your default.conf configuration file to make it easier to keep your data separate from your installation.

In this example we are defining a home directory of data/ which is located within the working directory (user.dir) of your microservice. We are also conditionally redefining that location to the value specified in the MYAPP_HOME environment variable, if that environment variable exists.

myapp.home = "data/"
myapp.home = ${?MYAPP_HOME}
Clone this wiki locally