├── .blaze
├── blaze.conf
├── blaze.java
└── pom.xml
├── .github
└── workflows
│ ├── java11.yaml
│ ├── java17.yaml
│ ├── java21.yaml
│ ├── java8.yaml
│ ├── macos-arm64.yaml
│ └── windows-x64.yaml
├── .gitignore
├── CHANGELOG.md
├── README.md
├── Vagrantfile
├── blaze.jar
├── buildx-results.txt
├── docs
├── CANONICAL_LAYOUT.md
└── DEV.md
├── pom.xml
├── setup
└── jsl.0.99x.zip
├── stork-assembly
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── fizzed
│ └── stork
│ └── assembly
│ ├── AssemblyMain.java
│ ├── AssemblyUtils.java
│ └── CopyFile.java
├── stork-bom
└── pom.xml
├── stork-cli
├── pom.xml
└── src
│ └── main
│ ├── launchers
│ ├── stork-deploy.yml
│ └── stork-launcher.yml
│ └── resources
│ └── logback.xml
├── stork-core
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── fizzed
│ └── stork
│ └── core
│ ├── ArgumentException.java
│ └── BaseApplication.java
├── stork-demo
├── stork-demo-dropwizard
│ ├── README.md
│ ├── conf
│ │ └── hello.yml
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── fizzed
│ │ │ └── stork
│ │ │ └── demo
│ │ │ └── dropwizard
│ │ │ ├── HelloApplication.java
│ │ │ ├── HelloConfiguration.java
│ │ │ └── HelloResource.java
│ │ └── launchers
│ │ └── stork-demo-dropwizard.yml
└── stork-demo-hellod
│ ├── Dockerfile
│ ├── README.md
│ ├── pom.xml
│ └── src
│ └── main
│ ├── java
│ └── com
│ │ └── fizzed
│ │ └── stork
│ │ └── demo
│ │ └── hellod
│ │ └── Hellod.java
│ ├── launchers
│ └── stork-demo-hellod.yml
│ └── resources
│ └── logback.xml
├── stork-deploy
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── fizzed
│ │ └── stork
│ │ └── deploy
│ │ ├── Archive.java
│ │ ├── Assembly.java
│ │ ├── Assemblys.java
│ │ ├── BasicFile.java
│ │ ├── CloseablePath.java
│ │ ├── Daemon.java
│ │ ├── DeployHelper.java
│ │ ├── DeployMain.java
│ │ ├── DeployOptions.java
│ │ ├── Deployer.java
│ │ ├── DeployerException.java
│ │ ├── Deployment.java
│ │ ├── DeploymentType.java
│ │ ├── Deployments.java
│ │ ├── ExistingDeployment.java
│ │ ├── InitType.java
│ │ ├── SshTarget.java
│ │ ├── SystemdHelper.java
│ │ ├── Target.java
│ │ ├── Targets.java
│ │ ├── UnixTarget.java
│ │ └── VersionedPath.java
│ └── test
│ ├── java
│ └── com
│ │ └── fizzed
│ │ └── stork
│ │ └── deploy
│ │ ├── AssemblysTest.java
│ │ ├── DeployMain.java
│ │ ├── DeployerBaseTest.java
│ │ ├── DeployerConsoleTest.java
│ │ ├── DeployerDaemonTest.java
│ │ ├── TargetsTest.java
│ │ └── TestHelper.java
│ ├── launchers
│ ├── stork-console1.yml
│ └── stork-daemon1.yml
│ └── resources
│ ├── fixtures
│ ├── hello-conf-1.2.4-SNAPSHOT.zip
│ ├── hello-console-1.2.4.tar.gz
│ ├── hello-console-1.2.4.zip
│ ├── hello-world-1.2.4-SNAPSHOT.tar.gz
│ └── hello-world-1.2.4-SNAPSHOT.zip
│ └── logback.xml
├── stork-gradle-plugin
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── pom.xml
└── src
│ ├── main
│ └── groovy
│ │ └── com
│ │ └── fizzed
│ │ └── stork
│ │ └── gradle
│ │ ├── StorkPlugin.groovy
│ │ └── tasks
│ │ ├── AssemblyExtension.groovy
│ │ ├── AssemblyTask.groovy
│ │ ├── LauncherExtension.groovy
│ │ ├── LaunchersExtension.groovy
│ │ └── LaunchersTask.groovy
│ └── test
│ └── groovy
│ └── com
│ └── fizzed
│ └── stork
│ └── gradle
│ └── StorkPluginTests.groovy
├── stork-launcher
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── fizzed
│ │ │ └── stork
│ │ │ └── launcher
│ │ │ ├── Configuration.java
│ │ │ ├── ConfigurationFactory.java
│ │ │ ├── FileUtil.java
│ │ │ ├── Generator.java
│ │ │ ├── JacksonUtil.java
│ │ │ ├── LauncherMain.java
│ │ │ ├── LauncherModel.java
│ │ │ ├── MergeMain.java
│ │ │ ├── Merger.java
│ │ │ └── PlatformConfiguration.java
│ └── resources
│ │ └── com
│ │ └── fizzed
│ │ └── stork
│ │ └── launcher
│ │ ├── linux
│ │ ├── initd-daemon.ftl
│ │ ├── script-console.ftl
│ │ ├── script-daemon-nohup.ftl
│ │ ├── script-functions.sh
│ │ ├── script-header.ftl
│ │ ├── script-java-detect-header.sh
│ │ ├── script-java-detect.sh
│ │ ├── script-java.ftl
│ │ ├── systemd-daemon.ftl
│ │ ├── test-function.sh
│ │ ├── test-java-detect.sh
│ │ └── test-loop.sh
│ │ ├── osx
│ │ └── launchd.ftl
│ │ └── windows
│ │ ├── batch-console.ftl
│ │ ├── batch-daemon-jslwin.ftl
│ │ ├── batch-find-java.bat
│ │ ├── batch-footer.ftl
│ │ ├── batch-header.ftl
│ │ ├── batch-java.ftl
│ │ ├── config-daemon-jslwin.ftl
│ │ ├── config-daemon-winsw.ftl
│ │ ├── jslwin
│ │ ├── jsl.exe
│ │ ├── jsl.jar
│ │ ├── jsl64.exe
│ │ ├── jsl64_debug.exe
│ │ └── jsl_debug.exe
│ │ └── winsw
│ │ ├── winsw-1.16-bin.exe
│ │ └── winsw.exe.config
│ └── test
│ ├── java
│ └── com
│ │ └── fizzed
│ │ └── stork
│ │ └── launcher
│ │ ├── LauncherTest.java
│ │ └── TestHelper.java
│ └── launchers
│ ├── cat.yml
│ ├── echo-console1.yml
│ ├── echo-console2.yml
│ ├── echo-console3.yml
│ └── echo-daemon1.yml
├── stork-maven-plugin
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── fizzed
│ └── stork
│ └── maven
│ ├── AssemblyMojo.java
│ ├── LauncherMojo.java
│ └── MergeMojo.java
└── stork-test-app
├── pom.xml
└── src
└── main
└── java
└── com
└── fizzed
└── stork
└── test
├── Arguments.java
├── CatMain.java
├── EchoConsoleMain.java
├── EchoDaemonMain.java
└── LaunchData.java
/.blaze/blaze.conf:
--------------------------------------------------------------------------------
1 | blaze.dependencies = [
2 | "com.fizzed:blaze-ssh"
3 | "com.fizzed:blaze-public-project:1.0.1"
4 | ]
5 |
6 | java.source.version = 8
7 |
--------------------------------------------------------------------------------
/.blaze/blaze.java:
--------------------------------------------------------------------------------
1 | import static com.fizzed.blaze.Contexts.fail;
2 | import static com.fizzed.blaze.Systems.exec;
3 | import static com.fizzed.blaze.Systems.which;
4 |
5 | import com.fizzed.blaze.project.PublicBlaze;
6 |
7 | import java.nio.file.Path;
8 |
9 | public class blaze extends PublicBlaze {
10 |
11 | private String getTestHost(boolean required) {
12 | String host = config.value("host").getOr("");
13 |
14 | if (host.equals("")) {
15 | log.info("NOTE: you can limit which host your unit tests run on");
16 | log.info(" by adding a -Dhost=HOST to your command. Valid hosts");
17 | log.info(" are either 'local' or run 'vagrant status' for a list");
18 | if (required) {
19 | fail("host is required");
20 | }
21 | } else {
22 | log.info("NOTE: limiting unit tests to host {}", host);
23 | }
24 |
25 | return host;
26 | }
27 |
28 | public void test_launcher() {
29 | String host = getTestHost(false);
30 | exec("mvn", "test", "-am", "-pl", "stork-launcher-test", "-Dhost=" + host).run();
31 | }
32 |
33 | public void test_deploy() {
34 | String host = getTestHost(false);
35 | exec("mvn", "test", "-am", "-pl", "stork-deploy", "-Dhost=" + host).run();
36 | }
37 |
38 | public void demo_launcher() {
39 | exec("mvn", "package", "-DskipTests=true", "-am", "-pl", "stork-cli").run();
40 | exec("stork-launcher", "-o", "target/stork-fake", "stork-cli/src/main/launchers")
41 | .workingDir("stork-cli/target/stork/bin")
42 | .run();
43 | }
44 |
45 | public void demo_deploy() {
46 | String host = getTestHost(true);
47 | exec("mvn", "package", "-DskipTests=true", "-am", "-pl", "stork-cli").run();
48 | exec("stork-deploy", "-a", "stork-deploy/src/test/resources/fixtures/hello-console-1.2.4.tar.gz", "vagrant+ssh://" + host)
49 | .workingDir("stork-cli/target/stork/bin")
50 | .run();
51 | }
52 |
53 | public void demo_hellod() {
54 | exec("mvn", "package", "-DskipTests=true", "-am", "-pl", "stork-demo/stork-demo-hellod").run();
55 | final Path command = which("stork-demo-hellod")
56 | .path("stork-demo/stork-demo-hellod/target/stork/bin")
57 | .run();
58 | exec(command, "--run")
59 | .run();
60 | }
61 |
62 | public void demo_dropwizard() {
63 | exec("mvn", "package", "-DskipTests=true", "-am", "-pl", "stork-demo/stork-demo-dropwizard").run();
64 | final Path command = which("stork-demo-dropwizard")
65 | .path("stork-demo/stork-demo-dropwizard/target/stork/bin")
66 | .run();
67 | exec(command, "--run")
68 | .env("EXTRA_JAVA_ARGS", "-Da=1")
69 | .run();
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/.blaze/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | blaze
4 | stork-blaze
5 | 0.0.1
6 |
7 |
12 |
13 |
14 | 8
15 | 8
16 | true
17 | true
18 |
19 |
20 | ${project.basedir}
21 |
22 |
23 |
24 | org.apache.ivy
25 | ivy
26 | 2.5.2
27 |
28 |
29 | com.fizzed
30 | blaze-core
31 | 1.8.0
32 |
33 |
34 | commons-io
35 | commons-io
36 | 2.16.1
37 |
38 |
39 | com.typesafe
40 | config
41 | 1.4.3
42 |
43 |
44 | com.fizzed
45 | blaze-ivy
46 | 1.8.0
47 |
48 |
49 | org.slf4j
50 | slf4j-simple
51 | 2.0.13
52 |
53 |
54 | org.slf4j
55 | slf4j-api
56 | 2.0.13
57 |
58 |
59 | org.zeroturnaround
60 | zt-exec
61 | 1.12
62 |
63 |
64 | com.fizzed
65 | blaze-ssh
66 | 1.8.0
67 |
68 |
69 | com.fizzed
70 | blaze-public-project
71 | 1.0.1
72 |
73 |
74 |
--------------------------------------------------------------------------------
/.github/workflows/java11.yaml:
--------------------------------------------------------------------------------
1 | name: Java 11
2 | on:
3 | - push
4 | - workflow_dispatch
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 | - name: Set up Azul JDK 11
11 | uses: actions/setup-java@v3
12 | with:
13 | java-version: 11
14 | distribution: 'zulu'
15 | cache: 'maven'
16 | - name: Build with Maven
17 | run: mvn test
18 |
--------------------------------------------------------------------------------
/.github/workflows/java17.yaml:
--------------------------------------------------------------------------------
1 | name: Java 17
2 | on:
3 | - push
4 | - workflow_dispatch
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 | - name: Set up Azul JDK 17
11 | uses: actions/setup-java@v3
12 | with:
13 | java-version: 17
14 | distribution: 'zulu'
15 | cache: 'maven'
16 | - name: Build with Maven
17 | run: mvn test
18 |
--------------------------------------------------------------------------------
/.github/workflows/java21.yaml:
--------------------------------------------------------------------------------
1 | name: Java 21
2 | on:
3 | - push
4 | - workflow_dispatch
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 | - name: Set up Azul JDK 21
11 | uses: actions/setup-java@v3
12 | with:
13 | java-version: 21
14 | distribution: 'zulu'
15 | cache: 'maven'
16 | - name: Build with Maven
17 | run: mvn test
18 |
--------------------------------------------------------------------------------
/.github/workflows/java8.yaml:
--------------------------------------------------------------------------------
1 | name: Java 8
2 | on:
3 | - push
4 | - workflow_dispatch
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 | - name: Set up Azul JDK 8
11 | uses: actions/setup-java@v3
12 | with:
13 | java-version: 8
14 | distribution: 'zulu'
15 | cache: 'maven'
16 | - name: Build with Maven
17 | run: mvn test
18 |
--------------------------------------------------------------------------------
/.github/workflows/macos-arm64.yaml:
--------------------------------------------------------------------------------
1 | name: MacOS arm64
2 | on:
3 | - push
4 | - workflow_dispatch
5 | jobs:
6 | build:
7 | runs-on: macos-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 | - name: Set up Azul JDK 11
11 | uses: actions/setup-java@v3
12 | with:
13 | java-version: 11
14 | distribution: 'zulu'
15 | cache: 'maven'
16 | - name: Build with Maven
17 | run: mvn test
18 |
--------------------------------------------------------------------------------
/.github/workflows/windows-x64.yaml:
--------------------------------------------------------------------------------
1 | name: Windows x64
2 | on:
3 | - push
4 | - workflow_dispatch
5 | jobs:
6 | build:
7 | runs-on: windows-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 | - name: Set up Azul JDK 11
11 | uses: actions/setup-java@v3
12 | with:
13 | java-version: 11
14 | distribution: 'zulu'
15 | cache: 'maven'
16 | - name: Build with Maven
17 | run: mvn test
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | .vagrant
3 | *.iml
4 | .buildx
5 |
--------------------------------------------------------------------------------
/Vagrantfile:
--------------------------------------------------------------------------------
1 | # -*- mode: ruby -*-
2 | # vi: set ft=ruby :
3 |
4 | Vagrant.configure(2) do |config|
5 |
6 | config.vm.define "ubuntu14" do |guest|
7 | guest.vm.box = "minimal/trusty64"
8 | guest.vm.box_version = "14.04.3"
9 | guest.vm.provision :shell, inline: "echo 'install depends'; apt-get update; apt-get install -y openjdk-7-jre-headless unzip curl"
10 | # unit tests required passing along env vars in ssh commands
11 | guest.vm.provision :shell, inline: "echo 'forcing sshd to accept env'; echo 'AcceptEnv *' >> /etc/ssh/sshd_config"
12 | guest.vm.provision :shell, inline: "echo 'restart sshd'; service ssh restart"
13 | end
14 |
15 | config.vm.define "ubuntu16" do |guest|
16 | guest.vm.box = "bento/ubuntu-16.04"
17 | guest.vm.box_version = "201801.02.0"
18 | guest.vm.provision :shell, inline: "echo 'install depends'; apt update; apt install -y openjdk-8-jre-headless unzip curl"
19 | # unit tests required passing along env vars in ssh commands
20 | guest.vm.provision :shell, inline: "echo 'forcing sshd to accept env'; echo 'AcceptEnv *' >> /etc/ssh/sshd_config"
21 | guest.vm.provision :shell, inline: "echo 'restart sshd'; service ssh restart"
22 | end
23 |
24 | config.vm.define "ubuntu20" do |guest|
25 | guest.vm.box = "bento/ubuntu-20.04"
26 | guest.vm.box_version = "202005.21.0"
27 | guest.vm.provision :shell, inline: "echo 'install depends'; apt update; apt install -y openjdk-11-jre-headless unzip curl"
28 | # unit tests required passing along env vars in ssh commands
29 | guest.vm.provision :shell, inline: "echo 'forcing sshd to accept env'; echo 'AcceptEnv *' >> /etc/ssh/sshd_config"
30 | guest.vm.provision :shell, inline: "echo 'restart sshd'; service ssh restart"
31 | end
32 |
33 | config.vm.define "windows10" do |guest|
34 | guest.vm.box = "giorgioinf/win10N-shell"
35 | guest.vm.box_version = "0.0.1"
36 | # box crawls to a halt if less than 2G of RAM
37 | guest.vm.provider "virtualbox" do |vb|
38 | vb.customize ["modifyvm", :id, "--memory", "2048"]
39 | end
40 | # go into box and then run "choco install -y jdk8"
41 | #guest.vm.provision :shell, powershell_elevated_interactive: true, privileged: true, inline: "choco install -y jdk8"
42 | #guest.vm.provision :shell, path: "https://raw.githubusercontent.com/xpando/Dash/master/PowerShell/Scripts/Install-JDK8.ps1"
43 | end
44 |
45 | config.vm.define "debian8", autostart: false do |guest|
46 | guest.vm.box = "minimal/jessie64"
47 | guest.vm.box_version = "8.0"
48 | guest.vm.provision :shell, inline: "apt-get update; apt-get install -y openjdk-7-jre-headless unzip curl"
49 | # unit tests required passing along env vars in ssh commands
50 | guest.vm.provision :shell, inline: "echo 'forcing sshd to accept env'; echo 'AcceptEnv *' >> /etc/ssh/sshd_config"
51 | guest.vm.provision :shell, inline: "/etc/init.d/ssh restart"
52 | end
53 |
54 | config.vm.define "centos7", autostart: false do |guest|
55 | guest.vm.box = "minimal/centos7"
56 | guest.vm.box_version = "7.0"
57 | guest.vm.provision :shell, inline: "yum install -y java-1.7.0-openjdk-headless unzip curl"
58 | # unit tests required passing along env vars in ssh commands
59 | guest.vm.provision :shell, inline: "echo 'forcing sshd to accept env'; echo 'UseDNS no' >> /etc/ssh/sshd_config"
60 | guest.vm.provision :shell, inline: "echo 'forcing sshd to accept env'; echo 'AcceptEnv *' >> /etc/ssh/sshd_config"
61 | guest.vm.provision :shell, inline: "systemctl restart sshd.service"
62 | end
63 |
64 | config.vm.define "freebsd10", autostart: false do |guest|
65 | guest.vm.box = "bento/freebsd-10.3"
66 | guest.vm.box_version = "201708.22.0"
67 | guest.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/"
68 | guest.vm.provision :shell, inline: "pkg install -y openjdk; echo 'fdesc /dev/fd fdescfs rw 0 0' >> /etc/fstab; echo 'proc /proc procfs rw 0 0' >> /etc/fstab; mount /dev/fd; mount /proc"
69 | # unit tests required passing along env vars in ssh commands
70 | guest.vm.provision :shell, inline: "echo 'AcceptEnv *' >> /etc/ssh/sshd_config"
71 | guest.vm.provision :shell, inline: "service sshd restart"
72 | end
73 |
74 | config.vm.define "openbsd60", autostart: false do |guest|
75 | guest.vm.box = "ryanmaclean/openbsd-6.0"
76 | guest.vm.provider "virtualbox" do |vb|
77 | vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
78 | end
79 | guest.ssh.sudo_command = "doas su -"
80 | guest.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__rsync_path: "doas rsync", rsync__exclude: ".git/"
81 | guest.vm.provision :shell, inline: "PKG_PATH=\"http://ftp.openbsd.org/pub/OpenBSD/`uname -r`/packages/`arch -s`/\" pkg_add -I wget--"
82 | guest.vm.provision :shell, inline: "cd /tmp; wget \"http://ftp.openbsd.org/pub/OpenBSD/`uname -r`/`arch -s`/xbase58.tgz\"; cd /; tar xzvphf /tmp/xbase58.tgz"
83 | guest.vm.provision :shell, inline: "PKG_PATH=\"http://ftp.openbsd.org/pub/OpenBSD/`uname -r`/packages/`arch -s`/\" pkg_add -I jdk-1.7.0.80p0v0"
84 | end
85 |
86 | config.vm.define "osx1010", autostart: false do |guest|
87 | guest.vm.box = "jhcook/osx-yosemite-10.10"
88 | guest.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/"
89 | end
90 |
91 | end
--------------------------------------------------------------------------------
/blaze.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fizzed/stork/fcf82d42d0ab0f18a3a9c4fd07394a2f7a1be672/blaze.jar
--------------------------------------------------------------------------------
/buildx-results.txt:
--------------------------------------------------------------------------------
1 | Buildx Results
2 | --------------
3 | Cross platform tests use the Buildx project: https://github.com/fizzed/buildx
4 | Commit: aa2d1b30848ab59157d0113644d6dacf4345ff14
5 | Date: 2025-01-20T18:58:28.564812Z[UTC]
6 |
7 | linux-x64 success
8 | linux-arm64 success
9 | linux-riscv64 success
10 | linux_musl-x64 success
11 | macos-x64 success
12 | macos-arm64 success
13 | windows-x64 success
14 | windows-arm64 success
15 | freebsd-x64 success
16 | openbsd-x64 success
17 |
18 |
--------------------------------------------------------------------------------
/docs/CANONICAL_LAYOUT.md:
--------------------------------------------------------------------------------
1 | Stork by Fizzed
2 | =======================================
3 |
4 | ## Canonical java application layout
5 |
6 | All of Stork's tools need to know where to look for various files in order to
7 | function in a standard way. Stork uses the following conventional app layout:
8 |
9 | / (
10 | bin/ (launcher scripts, overwrite on upgrade)
11 | lib/ (all jars, overwrite on upgrade, fat jars not recommended)
12 | share/ (arch indep data for install/running/info; overwrite on upgrade)
13 | conf/ (config files; retain on upgrade)
14 | data/ (not included in assembly/install; retain on upgrade)
15 | log/ (not included in assembly/install; retain on upgrade)
16 | run/ (not included in assembly/install; retain on upgrade)
17 |
18 | ### bin/ (executables)
19 |
20 | For all read-only executables. These are the binaries the user will execute to
21 | run your console application or start/stop your daemon. The executables should
22 | look and feel like a native application.
23 |
24 | Examples include batch files or shell scripts to start your Java app. Assume
25 | file permissions of 0775.
26 |
27 | ### lib/ (libraries)
28 |
29 | All shared files and libraries required for running the application(s).
30 |
31 | Examples include jar files containing compiled Java classes. Assume file permissions
32 | of 0664.
33 |
34 | ### conf/ (configuration data)
35 |
36 | All configuration files for the application(s). Any files in this directory
37 | need to be carefully examined during an upgrade -- since the user may have
38 | edited the config for their specific system. Assume file permissions of 0664.
39 |
40 | ### share/ (architecture-independent data)
41 |
42 | For all read-only architecture independent data files.
43 |
44 | Examples would include sql scripts to setup databases; linux/unix init.d scripts, or
45 | documentation. Assume this data will be overwritten on application upgrades.
46 | Assume file permissions of 0664.
47 |
48 | ### data/ (variable state information)
49 |
50 | State information is data that programs modify while they run, and that pertains
51 | to one specific host. State information remains valid after a reboot, should
52 | not be logging output, and should not be spooled data.
53 |
54 | Files in this directory should be retained between upgrades.
55 |
56 | Examples would include an application's database. On Linux/UNIX, this could/may be
57 | symlinked to /var/data/. Assume file permissions of 0644.
58 |
59 | ### log/ (logfiles)
60 |
61 | Logfiles for application (startup, runtime, etc.). It must be acceptable to
62 | truncate or delete files in this directory w/o affecting the application on
63 | its next invocation.
64 |
65 | Files in this directory may be retained between upgrades, but assume they will
66 | be deleted. On Linux/UNIX, this could be symlinked to /var/log/.
67 |
68 | ### run/ (run-time variable data)
69 |
70 | This directory contains system information data describing the system since it
71 | was booted. Files under this directory may/will be cleared (removed or truncated
72 | as appropriate) at the beginning of the boot process. On some versions of linux,
73 | /var/run is mounted as a temporary file system.
74 |
75 | Examples would include an application's process id (pid) file or named sockets.
76 | On Linux/UNIX, this could be symlinked to /var/run/.
77 |
--------------------------------------------------------------------------------
/docs/DEV.md:
--------------------------------------------------------------------------------
1 | Stork by Fizzed
2 | ===============
3 |
4 | ## Overview
5 |
6 | Stork heavily interacts with various operating systems. While many unit tests
7 | are designed to run locally (and not in a virtual machine), to truly do development
8 | with Stork you'll want to verify what you changed works across a number of
9 | operating systems.
10 |
11 | ## Vagrant
12 |
13 | Make sure you have at least Vagrant v1.9.8 installed as well as the extension pack.
14 | You can verify your version by running:
15 |
16 | vagrant -v
17 |
18 | Vagrant is used to help setup virtual machines running various operating systems
19 | so we can run unit tests against them. The unit tests are designed to detect what's
20 | virtual machines are running and then run tests against them -- so you only need to
21 | spin up what you'd like to test against. Let's run thru an "ubuntu14" example:
22 |
23 | To spin up an Ubuntu 14.04 virtual machine:
24 |
25 | vagrant up ubuntu14
26 |
27 | ## Running Unit Tests
28 |
29 | To run all unit tests against a specific virtual machine:
30 |
31 | mvn test -Dhost=ubuntu14
32 |
33 | To test only the stork-launcher module on that host:
34 |
35 | mvn -am -pl stork-launcher test -DfailIfNoTests=false -Dtest=com.fizzed.stork.launcher.*Test -Dhost=ubuntu14
36 |
37 | To test only the stork-deploy module on that host:
38 |
39 | mvn -am -pl stork-deploy test -DfailIfNoTests=false -Dtest=com.fizzed.stork.deploy.*Test -Dhost=ubuntu14
40 |
41 | To run your tests locally, just use the host of `local`:
42 |
43 | mvn test -Dhost=local
44 |
45 | ## Testing for Windows on Linux/Mac
46 |
47 | To run tests against Windows (if on Linux or OSX):
48 |
49 | vagrant up windows10
50 |
51 | Be patient as the image is ~6GB to download. Once ready, you'll need to make
52 | sure Java 8 is on it. We didn't have time to make the vagrant install do all
53 | the prep, so there's a couple manual steps. Open up VirtualBox, double click
54 | the vm, then open powershell:
55 |
56 | choco install -y jdk8
57 |
58 | Then you can run any of the tests above against the host `windows10`:
59 |
60 | mvn test -Dhost=windows10
61 |
62 | NOTE: its incredibly important your windows scripts have correct line endings or
63 | the Windows cmd.exe interpreter will give you strange results.
64 |
65 | unix2dos stork-launcher/src/main/resources/com/fizzed/stork/launcher/windows/*
--------------------------------------------------------------------------------
/setup/jsl.0.99x.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fizzed/stork/fcf82d42d0ab0f18a3a9c4fd07394a2f7a1be672/setup/jsl.0.99x.zip
--------------------------------------------------------------------------------
/stork-assembly/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.fizzed
5 | stork-assembly
6 | jar
7 | stork-assembly
8 |
9 |
10 | com.fizzed
11 | stork
12 | 3.2.1-SNAPSHOT
13 |
14 |
15 |
16 |
17 |
18 | org.slf4j
19 | slf4j-api
20 |
21 |
22 |
23 | com.fizzed
24 | stork-launcher
25 |
26 |
27 |
28 | org.apache.commons
29 | commons-compress
30 |
31 |
32 |
33 |
34 | org.hamcrest
35 | java-hamcrest
36 | test
37 |
38 |
39 |
40 | junit
41 | junit
42 | test
43 |
44 |
45 |
46 | org.mockito
47 | mockito-core
48 | test
49 |
50 |
51 |
52 | ch.qos.logback
53 | logback-classic
54 | test
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/stork-assembly/src/main/java/com/fizzed/stork/assembly/AssemblyMain.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fizzed.stork.assembly;
18 |
19 | import java.io.File;
20 | import org.slf4j.Logger;
21 | import org.slf4j.LoggerFactory;
22 |
23 | public class AssemblyMain {
24 | private static final Logger logger = LoggerFactory.getLogger(AssemblyMain.class);
25 |
26 | static public void main(String[] args) throws Exception {
27 | if (args.length != 3) {
28 | System.err.println("Expected 3 arguments");
29 | System.exit(1);
30 | }
31 |
32 | File outputDir = new File(args[0]);
33 | File inputDir = new File(args[1]);
34 | String name = args[2];
35 |
36 | File tgzFile = AssemblyUtils.createTGZ(outputDir, inputDir, name);
37 | logger.info("Created {}", tgzFile);
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/stork-assembly/src/main/java/com/fizzed/stork/assembly/AssemblyUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 mfizz.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fizzed.stork.assembly;
18 |
19 | import java.io.BufferedOutputStream;
20 | import java.io.File;
21 | import java.io.FileFilter;
22 | import java.io.FileInputStream;
23 | import java.io.FileOutputStream;
24 | import java.io.IOException;
25 | import java.util.zip.GZIPOutputStream;
26 | import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
27 | import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
28 | import org.apache.commons.io.FileUtils;
29 | import org.apache.commons.io.IOUtils;
30 | import org.slf4j.Logger;
31 | import org.slf4j.LoggerFactory;
32 |
33 | public class AssemblyUtils {
34 | private static final Logger logger = LoggerFactory.getLogger(AssemblyUtils.class);
35 |
36 | static public void copyStandardProjectResources(File projectDir, File outputDir) throws IOException {
37 | FileUtils.copyDirectory(projectDir, outputDir, new FileFilter() {
38 | @Override
39 | public boolean accept(File pathname) {
40 | String name = pathname.getName().toLowerCase();
41 | if (name.startsWith("readme") || name.startsWith("changelog") || name.startsWith("release") || name.startsWith("license")) {
42 | return true;
43 | } else {
44 | return false;
45 | }
46 | }
47 | });
48 | }
49 |
50 | /**
51 | * Create .tar.gz archive file "name.tar.gz" with the contents of inputDir
52 | * using the prefix of "/name"
53 | * @param outputDir
54 | * @param inputDir
55 | * @param name
56 | * @return
57 | * @throws IOException
58 | */
59 | static public File createTGZ(File outputDir, File inputDir, String name) throws IOException {
60 | // create tarball
61 | File tgzFile = new File(outputDir, name + ".tar.gz");
62 | try (TarArchiveOutputStream tgzout = AssemblyUtils.createTGZStream(tgzFile)) {
63 | addFileToTGZStream(tgzout, inputDir, name, false);
64 | }
65 | return tgzFile;
66 | }
67 |
68 | static public TarArchiveOutputStream createTGZStream(File tgzFile) throws IOException {
69 | TarArchiveOutputStream tgzout = new TarArchiveOutputStream(
70 | new GZIPOutputStream(
71 | new BufferedOutputStream(new FileOutputStream(tgzFile))));
72 | tgzout.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_STAR);
73 | tgzout.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
74 | return tgzout;
75 | }
76 |
77 | static public void addFileToTGZStream(TarArchiveOutputStream tgzout, File f, String base, boolean appendName) throws IOException {
78 | //File f = new File(path);
79 | String entryName = base;
80 | if (appendName) {
81 | if (!entryName.equals("")) {
82 | if (!entryName.endsWith("/")) {
83 | entryName += "/" + f.getName();
84 | } else {
85 | entryName += f.getName();
86 | }
87 | } else {
88 | entryName += f.getName();
89 | }
90 | }
91 | TarArchiveEntry tarEntry = new TarArchiveEntry(f, entryName);
92 |
93 | if (f.isFile()) {
94 | if (f.canExecute()) {
95 | // -rwxr-xr-x
96 | tarEntry.setMode(493);
97 | } else {
98 | // keep default mode
99 | }
100 | }
101 |
102 | tgzout.putArchiveEntry(tarEntry);
103 |
104 | if (f.isFile()) {
105 | try (FileInputStream in = new FileInputStream(f)) {
106 | IOUtils.copy(in, tgzout);
107 | }
108 | tgzout.closeArchiveEntry();
109 | } else {
110 | tgzout.closeArchiveEntry();
111 | File[] children = f.listFiles();
112 | if (children != null){
113 | for (File child : children) {
114 | logger.info(" adding: " + entryName + "/" + child.getName());
115 | addFileToTGZStream(tgzout, child, entryName + "/", true);
116 | }
117 | }
118 | }
119 | }
120 |
121 | }
122 |
--------------------------------------------------------------------------------
/stork-assembly/src/main/java/com/fizzed/stork/assembly/CopyFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fizzed.stork.assembly;
18 |
19 | import java.io.File;
20 | import java.io.IOException;
21 | import java.util.ArrayList;
22 | import java.util.List;
23 | import org.apache.commons.io.FileUtils;
24 | import org.slf4j.Logger;
25 | import org.slf4j.LoggerFactory;
26 |
27 | /**
28 | * Utility for copy files/dirs while retaining execute permissions.
29 | */
30 | public class CopyFile {
31 | private static final Logger logger = LoggerFactory.getLogger(CopyFile.class);
32 |
33 | static public void main(String[] args) throws Exception {
34 | new CopyFile().run(args);
35 | }
36 |
37 | public void run(String[] args) {
38 | if (args.length < 2) {
39 | System.err.println("At least two arguments required");
40 | System.exit(1);
41 | }
42 |
43 | File outputDir = new File(args[0]);
44 |
45 | List inputFiles = new ArrayList<>();
46 |
47 | for (int i = 1; i < args.length; i++) {
48 | inputFiles.add(new File(args[i]));
49 | }
50 |
51 | if (inputFiles.isEmpty()) {
52 | logger.error("No input file(s)/dir(s)");
53 | System.exit(1);
54 | }
55 |
56 | for (File inputFile : inputFiles) {
57 | try {
58 | if (inputFile.isDirectory()) {
59 | File[] files = inputFile.listFiles();
60 | for (File f : files) {
61 | copyFile(f, outputDir);
62 | }
63 | } else {
64 | copyFile(inputFile, outputDir);
65 | }
66 | } catch (Exception e) {
67 | logger.error("", e);
68 | System.exit(1);
69 | }
70 | }
71 | }
72 |
73 | public void copyFile(File inputFile, File outputDir) throws IOException {
74 | if (inputFile.isDirectory()) {
75 | File[] files = inputFile.listFiles();
76 | File newOutputDir = new File(outputDir, inputFile.getName());
77 | for (File f : files) {
78 | copyFile(f, newOutputDir);
79 | }
80 | } else {
81 | File outputFile = new File(outputDir, inputFile.getName());
82 | outputDir.mkdirs();
83 | logger.info(" copying " + inputFile + " to " + outputFile);
84 | FileUtils.copyFile(inputFile, outputFile);
85 | if (inputFile.canExecute()) {
86 | outputFile.setExecutable(true);
87 | }
88 | }
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/stork-bom/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | stork-bom
5 | stork-bom
6 | pom
7 |
8 |
9 | com.fizzed
10 | stork
11 | 3.2.1-SNAPSHOT
12 |
13 |
14 |
15 |
16 |
17 | com.fizzed
18 | stork-core
19 | ${project.version}
20 |
21 |
22 |
23 | com.fizzed
24 | stork-launcher
25 | ${project.version}
26 |
27 |
28 |
29 | com.fizzed
30 | stork-maven-plugin
31 | ${project.version}
32 |
33 |
34 |
35 | com.fizzed
36 | stork-assembly
37 | ${project.version}
38 |
39 |
40 |
41 | com.fizzed
42 | stork-deploy
43 | ${project.version}
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/stork-cli/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.fizzed
5 | stork-cli
6 | jar
7 | stork-cli
8 |
9 |
10 | com.fizzed
11 | stork
12 | 3.2.1-SNAPSHOT
13 |
14 |
15 |
16 | true
17 |
18 |
19 |
20 |
21 |
22 |
23 | com.fizzed
24 | stork-maven-plugin
25 | ${project.version}
26 |
27 |
28 | stork-launcher
29 | package
30 |
31 | launcher
32 |
33 |
34 |
35 | stork-assembly
36 | package
37 |
38 | assembly
39 |
40 |
41 | stork-${project.version}
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | com.fizzed
53 | stork-launcher
54 |
55 |
56 |
57 | com.fizzed
58 | stork-deploy
59 |
60 |
61 |
62 |
63 | com.fizzed
64 | blaze-core
65 | runtime
66 |
67 |
68 | org.apache.ivy
69 | ivy
70 |
71 |
72 |
73 |
74 |
75 | com.fizzed
76 | blaze-ssh
77 | runtime
78 |
79 |
80 |
81 | com.fizzed
82 | blaze-vagrant
83 | runtime
84 |
85 |
86 |
87 |
88 | ch.qos.logback
89 | logback-classic
90 | runtime
91 |
92 |
93 |
--------------------------------------------------------------------------------
/stork-cli/src/main/launchers/stork-deploy.yml:
--------------------------------------------------------------------------------
1 | name: "stork-deploy"
2 | domain: "com.fizzed.stork"
3 | display_name: "Stork Deploy by Fizzed"
4 | short_description: "Utility for deploying stork assemblies"
5 | type: CONSOLE
6 | main_class: "com.fizzed.stork.deploy.DeployMain"
7 | platforms: [ WINDOWS, LINUX ]
8 | working_dir_mode: RETAIN
9 | min_java_version: "1.8"
10 | symlink_java: false
--------------------------------------------------------------------------------
/stork-cli/src/main/launchers/stork-launcher.yml:
--------------------------------------------------------------------------------
1 | name: "stork-launcher"
2 | domain: "com.fizzed.stork"
3 | display_name: "Stork Launcher Generator by Fizzed"
4 | short_description: "Utility for creating scripts to launch Java apps"
5 | type: CONSOLE
6 | main_class: "com.fizzed.stork.launcher.LauncherMain"
7 | platforms: [ WINDOWS, LINUX ]
8 | working_dir_mode: RETAIN
9 | min_java_version: "1.6"
10 | symlink_java: false
--------------------------------------------------------------------------------
/stork-cli/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | [%level] %msg%n
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/stork-core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.fizzed
5 | stork-core
6 | jar
7 | stork-core
8 |
9 |
10 | com.fizzed
11 | stork
12 | 3.2.1-SNAPSHOT
13 |
14 |
15 |
16 | com.fizzed.stork.core
17 |
18 |
19 |
20 |
21 |
22 | org.slf4j
23 | slf4j-api
24 |
25 |
26 |
27 |
28 | org.hamcrest
29 | java-hamcrest
30 | test
31 |
32 |
33 |
34 | junit
35 | junit
36 | test
37 |
38 |
39 |
40 | org.mockito
41 | mockito-core
42 | test
43 |
44 |
45 |
46 | ch.qos.logback
47 | logback-classic
48 | test
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/stork-core/src/main/java/com/fizzed/stork/core/ArgumentException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Fizzed Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fizzed.stork.core;
18 |
19 | public class ArgumentException extends Exception {
20 |
21 | /**
22 | * Creates a new instance of ArgumentException
without detail
23 | * message.
24 | */
25 | public ArgumentException() {
26 | }
27 |
28 | /**
29 | * Constructs an instance of ArgumentException
with the
30 | * specified detail message.
31 | *
32 | * @param msg the detail message.
33 | */
34 | public ArgumentException(String msg) {
35 | super(msg);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/stork-core/src/main/java/com/fizzed/stork/core/BaseApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.core;
17 |
18 | import java.util.ArrayDeque;
19 | import java.util.Arrays;
20 | import java.util.Deque;
21 | import org.slf4j.Logger;
22 | import org.slf4j.LoggerFactory;
23 |
24 | public abstract class BaseApplication {
25 |
26 | public abstract void printUsage();
27 |
28 | public Logger getLogger() {
29 | return LoggerFactory.getLogger(this.getClass());
30 | }
31 |
32 | public void logWelcomeMessage() {
33 | Logger log = getLogger();
34 | log.info(" __ __ ");
35 | log.info(" _______/ |_ ___________| | __");
36 | log.info(" / ___/\\ __\\/ _ \\_ __ \\ |/ /");
37 | log.info(" \\___ \\ | | ( <_> ) | \\/ < ");
38 | log.info("/____ > |__| \\____/|__| |__|_ \\");
39 | log.info(" \\/ \\/");
40 | log.info(" v" + Version.getVersion());
41 | log.info("");
42 | }
43 |
44 | public void printError(String errorMessage) {
45 | System.err.println("Error: " + errorMessage);
46 | }
47 |
48 | public void printUsageAndExitWithError() {
49 | printUsage();
50 | System.exit(1);
51 | }
52 |
53 | public void printErrorThenHelpHintAndExit(String errorMessage) {
54 | printError(errorMessage);
55 | System.out.println("Try with -h argument for usage info");
56 | System.exit(1);
57 | }
58 |
59 | public String nextArg(String arg, Deque args) {
60 | if (args.isEmpty()) {
61 | printErrorThenHelpHintAndExit("argument '" + arg + "' requires a value as the next argument");
62 | }
63 | return args.remove();
64 | }
65 |
66 | final public void run(String[] args) {
67 | run(new ArrayDeque<>(Arrays.asList(args)));
68 | }
69 |
70 | public abstract void run(Deque args);
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/stork-demo/stork-demo-dropwizard/README.md:
--------------------------------------------------------------------------------
1 | Stork by Fizzed
2 | =======================================
3 |
4 | ## Overview
5 |
6 | Stork example project demonstrating the following:
7 |
8 | - Maven build system using Stork Maven plugin to create launchers and assembly
9 | during package phase.
10 | - DropWizard-based HTTP server
11 |
--------------------------------------------------------------------------------
/stork-demo/stork-demo-dropwizard/conf/hello.yml:
--------------------------------------------------------------------------------
1 | server:
2 |
3 | applicationConnectors:
4 | - type: http
5 | port: 8080
6 |
7 | adminConnectors:
8 | - type: http
9 | port: 8081
10 |
--------------------------------------------------------------------------------
/stork-demo/stork-demo-dropwizard/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.fizzed
5 | stork-demo-dropwizard
6 | jar
7 | stork-demo-dropwizard
8 |
9 |
10 | com.fizzed
11 | stork
12 | 3.2.1-SNAPSHOT
13 | ../../pom.xml
14 |
15 |
16 |
17 | true
18 | com.fizzed.stork.demo.dropwizard
19 | 0.7.1
20 | 2.3.3
21 | true
22 |
23 |
24 |
25 |
26 |
27 |
28 | com.fizzed
29 | stork-maven-plugin
30 | ${project.version}
31 |
32 |
33 | stork-launcher
34 | package
35 |
36 | launcher
37 |
38 |
39 |
40 | stork-assembly
41 | package
42 |
43 | assembly
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | io.dropwizard
55 | dropwizard-core
56 | ${dropwizard.version}
57 |
58 |
59 | io.dropwizard
60 | dropwizard-views-freemarker
61 | ${dropwizard.version}
62 |
63 |
64 | io.dropwizard
65 | dropwizard-assets
66 | ${dropwizard.version}
67 |
68 |
69 | ch.qos.logback
70 | logback-classic
71 | runtime
72 |
73 |
74 |
75 |
76 | jakarta.xml.bind
77 | jakarta.xml.bind-api
78 | 2.3.2
79 |
80 |
81 |
82 |
83 | org.glassfish.jaxb
84 | jaxb-runtime
85 | 2.3.2
86 |
87 |
88 |
89 |
90 | junit
91 | junit
92 | test
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/stork-demo/stork-demo-dropwizard/src/main/java/com/fizzed/stork/demo/dropwizard/HelloApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 mfizz.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.demo.dropwizard;
17 |
18 | import io.dropwizard.Application;
19 | import io.dropwizard.setup.Bootstrap;
20 | import io.dropwizard.setup.Environment;
21 | import io.dropwizard.views.ViewBundle;
22 |
23 | public class HelloApplication extends Application {
24 | public static void main(String[] args) throws Exception {
25 | new HelloApplication().run(args);
26 | }
27 |
28 | @Override
29 | public String getName() {
30 | return "hello-dropwizard";
31 | }
32 |
33 | @Override
34 | public void initialize(Bootstrap bootstrap) {
35 | bootstrap.addBundle(new ViewBundle());
36 | }
37 |
38 | @Override
39 | public void run(HelloConfiguration configuration, Environment environment) throws ClassNotFoundException {
40 | environment.jersey().register(new HelloResource());
41 | }
42 | }
--------------------------------------------------------------------------------
/stork-demo/stork-demo-dropwizard/src/main/java/com/fizzed/stork/demo/dropwizard/HelloConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 mfizz.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.demo.dropwizard;
17 |
18 | import io.dropwizard.Configuration;
19 |
20 | public class HelloConfiguration extends Configuration {
21 |
22 | // nothing
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/stork-demo/stork-demo-dropwizard/src/main/java/com/fizzed/stork/demo/dropwizard/HelloResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 mfizz.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.demo.dropwizard;
17 |
18 | import com.codahale.metrics.annotation.Timed;
19 | import com.google.common.base.Optional;
20 | import io.dropwizard.jersey.caching.CacheControl;
21 | import java.util.Date;
22 |
23 | import javax.ws.rs.*;
24 | import javax.ws.rs.core.MediaType;
25 | import java.util.concurrent.TimeUnit;
26 | import javax.ws.rs.core.Response;
27 |
28 | @Path("/")
29 | @Produces(MediaType.TEXT_HTML)
30 | public class HelloResource {
31 |
32 | static Date startedAt = new Date();
33 |
34 | public HelloResource() {
35 | // do nothing
36 | }
37 |
38 | @GET
39 | @Timed
40 | @CacheControl(maxAge = 1, maxAgeUnit = TimeUnit.DAYS)
41 | public Response index(@QueryParam("name") Optional name) {
42 | return Response.ok(createBody()).build();
43 |
44 | }
45 |
46 | static String[] sysprops = { "user.dir","user.name","user.home","launcher.name","launcher.type","launcher.action","launcher.app.dir","java.class.path","java.home","java.version","java.vendor","os.arch","os.name","os.version" };
47 |
48 | static public String createBody() {
49 | StringBuilder sb = new StringBuilder();
50 | sb.append("");
51 | sb.append("Hello Server using DropWizard!");
52 | sb.append("");
53 | sb.append("");
54 | sb.append("Example using DropWizard
");
55 | // Version.java auto created by Fizzed parent POM file (I use this in all my projects)
56 | sb.append("Version: ").append(com.fizzed.stork.demo.dropwizard.Version.getLongVersion()).append("
");
57 | sb.append("Now: ").append(new Date()).append("
");
58 | sb.append("Started: ").append(startedAt).append("
");
59 | sb.append("Some system properties:
");
60 | for (String sysprop : sysprops) {
61 | sb.append(" - ").append(sysprop).append(": ").append(System.getProperty(sysprop)).append("
");
62 | }
63 | sb.append("");
64 | sb.append("");
65 | return sb.toString();
66 | }
67 |
68 | }
--------------------------------------------------------------------------------
/stork-demo/stork-demo-dropwizard/src/main/launchers/stork-demo-dropwizard.yml:
--------------------------------------------------------------------------------
1 |
2 | # Name of application (make sure it has no spaces)
3 | name: "stork-demo-dropwizard"
4 |
5 | # Domain of application (e.g. com.example)
6 | domain: "com.fizzed.stork.demo"
7 |
8 | # Display name of application (can have spaces)
9 | # Usually also the application directory for Windows/Mac OSX (e.g. Program Files\Hello Server)
10 | display_name: "Stork dropwizard demo"
11 |
12 | short_description: "Stork dropwizard demo"
13 |
14 | # Type of launcher (CONSOLE or DAEMON)
15 | type: DAEMON
16 |
17 | # Java class to run
18 | main_class: "com.fizzed.stork.demo.dropwizard.HelloApplication"
19 |
20 | # Platform launchers to generate (WINDOWS, LINUX, MAC_OSX)
21 | platforms: [ WINDOWS, LINUX, MAC_OSX ]
22 |
23 | # Include a share/helper/java-detect script (troubleshoot JVM searching, or
24 | # use within an installer / deployer)
25 | include_java_detect_helper: true
26 |
27 | # Working directory for app
28 | # RETAIN will not change the working directory
29 | # APP_HOME will change the workding directory to the home of the app
30 | #working_dir_mode: APP_HOME
31 |
32 | # Arguments for application (as though user typed them on command-line)
33 | # These will be added immediately after the main class part of java command
34 | app_args: "server conf/hello.yml"
35 |
36 | # Arguments to use with the java command (e.g. way to pass -D arguments)
37 | # "-Xrs" is good to include with daemons
38 | java_args: "-Xrs"
39 |
40 | # minimum version of java required (system will be searched for acceptable jvm)
41 | min_java_version: "1.7"
42 |
43 | # min/max fixed memory (measured in MB)
44 | #min_java_memory: 256
45 | #max_java_memory: 1024
46 |
47 | # min/max memory by percentage of system
48 | #min_java_memory_pct: 10
49 | #max_java_memory_pct: 80
50 |
51 | platform_configurations:
52 | LINUX:
53 | daemon_method: NOHUP
54 | user: "daemon"
55 | group: "daemon"
56 |
57 | MAC_OSX:
58 | user: "_daemon"
59 | group: "_daemon"
60 |
61 | WINDOWS:
62 | daemon_method: JSLWIN
63 |
64 | symlink_java: true
65 |
66 | #run_dir: /var/run
--------------------------------------------------------------------------------
/stork-demo/stork-demo-hellod/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright 2017 Fizzed, Inc.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | FROM openjdk:8-jre
15 | COPY target/stork /opt/demo-hellod
16 | # --run will allow you to still CTRL-C vs. --exec
17 | CMD ["/opt/demo-hellod/bin/stork-demo-hellod", "--run"]
--------------------------------------------------------------------------------
/stork-demo/stork-demo-hellod/README.md:
--------------------------------------------------------------------------------
1 | Stork by Fizzed
2 | ===============
3 |
4 | Example of a DAEMON/SERVICE Java app.
5 |
6 | Uses the stork maven plugin to generate launchers from [src/main/launchers](src/main/launchers)
7 | and then package the app into an assembly.
8 |
--------------------------------------------------------------------------------
/stork-demo/stork-demo-hellod/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.fizzed
5 | stork-demo-hellod
6 | jar
7 | stork-demo-hellod
8 |
9 |
10 | com.fizzed
11 | stork
12 | 3.2.1-SNAPSHOT
13 | ../../pom.xml
14 |
15 |
16 |
17 | com.fizzed.stork.demo.hellod
18 | true
19 |
20 |
21 |
22 |
23 |
24 |
25 | com.fizzed
26 | stork-maven-plugin
27 | ${project.version}
28 |
29 |
30 | stork-launcher
31 | package
32 |
33 | launcher
34 |
35 |
36 |
37 | stork-assembly
38 | package
39 |
40 | assembly
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | io.netty
52 | netty-codec-http
53 | 4.0.23.Final
54 |
55 |
56 |
57 |
58 | ch.qos.logback
59 | logback-classic
60 | runtime
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/stork-demo/stork-demo-hellod/src/main/launchers/stork-demo-hellod.yml:
--------------------------------------------------------------------------------
1 |
2 | # Name of application (make sure it has no spaces)
3 | name: "stork-demo-hellod"
4 |
5 | # Domain of application (e.g. com.example)
6 | domain: "com.fizzed.stork.demo"
7 |
8 | # Display name of application (can have spaces)
9 | # Usually also the application directory for Windows/Mac OSX (e.g. Program Files\Hello Server)
10 | display_name: "Stork Hello Server"
11 |
12 | short_description: "Stork Hello Server"
13 |
14 | # Type of launcher (CONSOLE or DAEMON)
15 | type: DAEMON
16 |
17 | # Java class to run
18 | main_class: "com.fizzed.stork.demo.hellod.Hellod"
19 |
20 | # Platform launchers to generate (WINDOWS, LINUX, MAC_OSX)
21 | platforms: [ WINDOWS, LINUX, MAC_OSX ]
22 |
23 | # Working directory for app
24 | # RETAIN will not change the working directory
25 | # APP_HOME will change the workding directory to the home of the app
26 | #working_dir_mode: APP_HOME
27 |
28 | # Arguments for application (as though user typed them on command-line)
29 | # These will be added immediately after the main class part of java command
30 | #app_args: "-c config.yml"
31 |
32 | # Arguments to use with the java command (e.g. way to pass -D arguments)
33 | # "-Xrs" is good to include with daemons
34 | java_args: "-Xrs"
35 |
36 | # minimum version of java required (system will be searched for acceptable jvm)
37 | min_java_version: "1.6"
38 |
39 | # min/max fixed memory (measured in MB)
40 | #min_java_memory: 30
41 | #max_java_memory: 256
42 |
43 | # min/max memory by percentage of system
44 | #min_java_memory_pct: 10
45 | #max_java_memory_pct: 80
46 |
47 | platform_configurations:
48 | LINUX:
49 | daemon_method: NOHUP
50 | user: "daemon"
51 | group: "daemon"
52 |
53 | MAC_OSX:
54 | user: "_daemon"
55 | group: "_daemon"
56 |
57 | WINDOWS:
58 | daemon_method: JSLWIN
59 |
60 | symlink_java: true
61 |
62 | #run_dir: /var/run
--------------------------------------------------------------------------------
/stork-demo/stork-demo-hellod/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | %-5level: %logger{36} - %msg%n
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/stork-deploy/src/main/java/com/fizzed/stork/deploy/Assemblys.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.deploy;
17 |
18 | import com.fizzed.blaze.util.Globber;
19 | import java.io.Closeable;
20 | import java.io.IOException;
21 | import java.nio.file.Files;
22 | import java.nio.file.Path;
23 | import java.util.ArrayList;
24 | import java.util.Arrays;
25 | import java.util.List;
26 | import org.slf4j.Logger;
27 | import org.slf4j.LoggerFactory;
28 |
29 | public class Assemblys {
30 | static private final Logger log = LoggerFactory.getLogger(Assemblys.class);
31 |
32 | static public Assembly process(Path archiveFile) throws IOException {
33 | Path tempDir = Files.createTempDirectory("stork-deploy.");
34 | CloseablePath closeablePath = new CloseablePath(tempDir);
35 | return process(archiveFile, tempDir, Arrays.asList(closeablePath));
36 | }
37 |
38 | static public Assembly process(Path archiveFile, Path workDir, List resources) throws IOException {
39 | if (!Files.exists(archiveFile)) {
40 | throw new IOException("Archive file " + archiveFile + " does not exist");
41 | }
42 |
43 | Archive archive = new Archive(archiveFile);
44 |
45 | Path unpackedDir = archive.unpack(workDir);
46 |
47 | String filename = unpackedDir.getFileName().toString();
48 |
49 | boolean snapshot = false;
50 | if (filename.endsWith("-SNAPSHOT")) {
51 | snapshot = true;
52 | filename = filename.replace("-SNAPSHOT", "");
53 | }
54 |
55 | // find version and strip it out
56 | int versionPos = filename.lastIndexOf("-");
57 | if (versionPos < 0) {
58 | throw new IOException("Unable to parse version from " + filename);
59 | }
60 |
61 | String version = filename.substring(versionPos+1);
62 | String name = filename.substring(0, versionPos);
63 |
64 | // find all supported daemon init types
65 | List daemons = new ArrayList<>();
66 |
67 | findSysvDaemons(unpackedDir, daemons);
68 | findSystemdDaemons(unpackedDir, daemons);
69 |
70 | return new Assembly(archive, unpackedDir, name, version, snapshot, daemons, resources);
71 | }
72 |
73 | static private void findSysvDaemons(Path unpackedDir, List daemons) throws IOException {
74 | Path dir = unpackedDir.resolve("share/init.d");
75 |
76 | if (!Files.exists(dir)) {
77 | log.debug("{} dir not found (no sysv daemons?)", dir);
78 | return;
79 | }
80 |
81 | Globber.globber(dir, "*.init").filesOnly().stream().forEach((initFile) -> {
82 | log.debug("Detected sysv daemon {}", initFile);
83 | String name = initFile.getFileName().toString().replace(".init", "");
84 | daemons.add(new Daemon(InitType.SYSV, name, null, null));
85 | });
86 | }
87 |
88 | static private void findSystemdDaemons(Path unpackedDir, List daemons) throws IOException {
89 | Path dir = unpackedDir.resolve("share/systemd");
90 |
91 | if (!Files.exists(dir)) {
92 | log.debug("{} dir not found (no systemd daemons?)", dir);
93 | return;
94 | }
95 |
96 | Globber.globber(dir, "*.service").filesOnly().stream().forEach((serviceFile) -> {
97 | log.debug("Detected systemd daemon {}", serviceFile);
98 | String name = serviceFile.getFileName().toString().replace(".service", "");
99 | daemons.add(new Daemon(InitType.SYSTEMD, name, null, null));
100 | });
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/stork-deploy/src/main/java/com/fizzed/stork/deploy/BasicFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.deploy;
17 |
18 | import java.io.File;
19 | import java.nio.file.Path;
20 |
21 | public class BasicFile {
22 |
23 | private final Path path;
24 | private final long createdAt;
25 | private final int userId;
26 | private final int groupId;
27 |
28 | public BasicFile(Path path, long createdAt, int userId, int groupId) {
29 | this.path = path;
30 | this.createdAt = createdAt;
31 | this.userId = userId;
32 | this.groupId = groupId;
33 | }
34 |
35 | public Path getPath() {
36 | return path;
37 | }
38 |
39 | public long getCreatedAt() {
40 | return createdAt;
41 | }
42 |
43 | public int getUserId() {
44 | return userId;
45 | }
46 |
47 | public int getGroupId() {
48 | return groupId;
49 | }
50 |
51 | @Override
52 | public String toString() {
53 | return path.toString();
54 | }
55 |
56 | static public String pathToUnixString(Path path) {
57 | if (path == null) {
58 | return null;
59 | }
60 | String s = path.toString();
61 | if (File.separatorChar == '\\') {
62 | s = s.replace('\\', '/');
63 | }
64 | return s;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/stork-deploy/src/main/java/com/fizzed/stork/deploy/CloseablePath.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.deploy;
17 |
18 | import java.io.Closeable;
19 | import java.io.IOException;
20 | import java.nio.file.Path;
21 |
22 | public class CloseablePath implements Closeable {
23 |
24 | private final Path path;
25 |
26 | public CloseablePath(Path path) {
27 | this.path = path;
28 | }
29 |
30 | public Path getPath() {
31 | return path;
32 | }
33 |
34 | @Override
35 | public void close() throws IOException {
36 | DeployHelper.deleteRecursively(this.path);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/stork-deploy/src/main/java/com/fizzed/stork/deploy/Daemon.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.deploy;
17 |
18 | import java.util.Objects;
19 |
20 | public class Daemon {
21 |
22 | private final InitType initType;
23 | private final String name;
24 | private final String user;
25 | private final String group;
26 |
27 | public Daemon(InitType initType, String name, String user, String group) {
28 | this.name = name;
29 | this.initType = initType;
30 | this.user = user;
31 | this.group = group;
32 | }
33 |
34 | public InitType getInitType() {
35 | return initType;
36 | }
37 |
38 | public String getName() {
39 | return name;
40 | }
41 |
42 | public String getUser() {
43 | return user;
44 | }
45 |
46 | public String getGroup() {
47 | return group;
48 | }
49 |
50 | @Override
51 | public int hashCode() {
52 | int hash = 3;
53 | hash = 37 * hash + Objects.hashCode(this.initType);
54 | hash = 37 * hash + Objects.hashCode(this.name);
55 | return hash;
56 | }
57 |
58 | @Override
59 | public boolean equals(Object obj) {
60 | if (this == obj) {
61 | return true;
62 | }
63 | if (obj == null) {
64 | return false;
65 | }
66 | if (getClass() != obj.getClass()) {
67 | return false;
68 | }
69 | final Daemon other = (Daemon) obj;
70 | if (!Objects.equals(this.name, other.name)) {
71 | return false;
72 | }
73 | if (this.initType != other.initType) {
74 | return false;
75 | }
76 | return true;
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/stork-deploy/src/main/java/com/fizzed/stork/deploy/DeployHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.deploy;
17 |
18 | import java.io.IOException;
19 | import java.nio.file.FileVisitResult;
20 | import java.nio.file.Files;
21 | import java.nio.file.Path;
22 | import java.nio.file.SimpleFileVisitor;
23 | import java.nio.file.attribute.BasicFileAttributes;
24 | import java.time.Instant;
25 | import java.time.LocalDateTime;
26 | import java.time.ZoneOffset;
27 | import java.time.format.DateTimeFormatter;
28 | import java.util.Locale;
29 | import org.slf4j.Logger;
30 | import org.slf4j.LoggerFactory;
31 |
32 | public class DeployHelper {
33 | private static final Logger log = LoggerFactory.getLogger(DeployHelper.class);
34 |
35 | static public void deleteRecursively(final Path path) throws IOException {
36 | if (!Files.exists(path)) {
37 | return;
38 | }
39 |
40 | log.info("Deleting local {}", path);
41 |
42 | Files.walkFileTree(path, new SimpleFileVisitor() {
43 | @Override
44 | public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
45 | //try {
46 | // if (!Files.isWritable(file)) {
47 | // log.error("File {} is not writable!!!", file);
48 | // }
49 | Files.deleteIfExists(file);
50 | //} catch (IOException e) {
51 | // log.error("Unable to delete {} wth attrs {}", file, attrs, e);
52 | //}
53 | return FileVisitResult.CONTINUE;
54 | }
55 |
56 | @Override
57 | public FileVisitResult postVisitDirectory(Path dir, IOException ioe) throws IOException {
58 | Files.deleteIfExists(dir);
59 | return FileVisitResult.CONTINUE;
60 | }
61 |
62 | @Override
63 | public FileVisitResult visitFileFailed(Path file, IOException ioe) throws IOException {
64 | return FileVisitResult.SKIP_SUBTREE;
65 | }
66 | });
67 |
68 | Files.deleteIfExists(path);
69 | }
70 |
71 | static private final DateTimeFormatter versionDateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss", Locale.US);
72 |
73 | static public String toVersionDateTime(long millis) {
74 | Instant instant = Instant.ofEpochMilli(millis);
75 | LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneOffset.UTC);
76 | return ldt.format(versionDateTimeFormatter);
77 | }
78 |
79 | static public String toFriendlyDateTime(long millis) {
80 | Instant instant = Instant.ofEpochMilli(millis);
81 | LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneOffset.UTC);
82 | return ldt.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/stork-deploy/src/main/java/com/fizzed/stork/deploy/DeployOptions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.deploy;
17 |
18 | import java.io.IOException;
19 | import java.io.InputStream;
20 | import java.nio.file.Files;
21 | import java.nio.file.Path;
22 | import java.util.Properties;
23 |
24 | public class DeployOptions {
25 |
26 | private String prefixDir;
27 | private String organization;
28 | private String user;
29 | private String group;
30 | private Boolean unattended;
31 | private Integer retain;
32 |
33 | public DeployOptions() {
34 | // no defaults!
35 | }
36 |
37 | public String getPrefixDir() {
38 | return prefixDir;
39 | }
40 |
41 | public DeployOptions prefixDir(String prefixDir) {
42 | this.prefixDir = prefixDir;
43 | return this;
44 | }
45 |
46 | public String getOrganization() {
47 | return organization;
48 | }
49 |
50 | public DeployOptions organization(String organization) {
51 | this.organization = organization;
52 | return this;
53 | }
54 |
55 | public String getUser() {
56 | return user;
57 | }
58 |
59 | public DeployOptions user(String user) {
60 | this.user = user;
61 | return this;
62 | }
63 |
64 | public String getGroup() {
65 | return group;
66 | }
67 |
68 | public DeployOptions group(String group) {
69 | this.group = group;
70 | return this;
71 | }
72 |
73 | public Boolean getUnattended() {
74 | return unattended;
75 | }
76 |
77 | public DeployOptions unattended(Boolean unattended) {
78 | this.unattended = unattended;
79 | return this;
80 | }
81 |
82 | public boolean safeUnattended() {
83 | return this.unattended != null && this.unattended;
84 | }
85 |
86 | public Integer getRetain() {
87 | return retain;
88 | }
89 |
90 | public DeployOptions retain(Integer retain) {
91 | this.retain = retain;
92 | return this;
93 | }
94 |
95 | public void overlay(DeployOptions options) {
96 | if (options == null) { return; }
97 | if (options.prefixDir != null) { this.prefixDir = options.prefixDir; }
98 | if (options.organization != null) { this.organization = options.organization; }
99 | if (options.user != null) { this.user = options.user; }
100 | if (options.group != null) { this.group = options.group; }
101 | if (options.unattended != null) { this.unattended = options.unattended; }
102 | if (options.retain != null) { this.retain = options.retain; }
103 | }
104 |
105 | static public DeployOptions from(Path file) throws IOException {
106 | Properties properties = new Properties();
107 | try (InputStream is = Files.newInputStream(file)) {
108 | properties.load(is);
109 | }
110 | return from(properties);
111 | }
112 |
113 | static public DeployOptions from(Properties properties) {
114 | DeployOptions options = new DeployOptions();
115 | options.prefixDir = properties.getProperty("prefix.dir");
116 | options.organization = properties.getProperty("organization");
117 | options.user = properties.getProperty("user");
118 | options.group = properties.getProperty("group");
119 | String unattendedValue = properties.getProperty("unattended");
120 | if (unattendedValue != null) {
121 | options.unattended = Boolean.valueOf(unattendedValue);
122 | }
123 | String retainValue = properties.getProperty("retain");
124 | if (retainValue != null) {
125 | options.retain = Integer.valueOf(retainValue);
126 | }
127 | return options;
128 | }
129 |
130 | }
131 |
--------------------------------------------------------------------------------
/stork-deploy/src/main/java/com/fizzed/stork/deploy/DeployerException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.deploy;
17 |
18 | public class DeployerException extends Exception {
19 |
20 | public DeployerException(String msg) {
21 | super(msg);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/stork-deploy/src/main/java/com/fizzed/stork/deploy/Deployment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.deploy;
17 |
18 | import java.util.Optional;
19 | import java.util.UUID;
20 |
21 | public class Deployment {
22 |
23 | private final String uuid;
24 | private final String baseDir;
25 | private final String currentDir;
26 | private final String versionDir;
27 | private final Optional user;
28 | private final Optional group;
29 |
30 | public Deployment(String baseDir, String currentDir, String versionDir, String user, String group) {
31 | this.uuid = UUID.randomUUID().toString();
32 | this.baseDir = baseDir;
33 | this.currentDir = currentDir;
34 | this.versionDir = versionDir;
35 | this.user = Optional.ofNullable(user);
36 | this.group = Optional.ofNullable(group);
37 | }
38 |
39 | public String getUuid() {
40 | return uuid;
41 | }
42 |
43 | public String getBaseDir() {
44 | return baseDir;
45 | }
46 |
47 | public String getCurrentDir() {
48 | return currentDir;
49 | }
50 |
51 | public String getVersionDir() {
52 | return versionDir;
53 | }
54 |
55 | public Optional getUser() {
56 | return user;
57 | }
58 |
59 | public Optional getGroup() {
60 | return group;
61 | }
62 |
63 | public Optional getOwner() {
64 | if (!this.user.isPresent()) {
65 | return Optional.empty();
66 | } else {
67 | if (this.group.isPresent()) {
68 | return Optional.of(this.user.get() + ":" + this.group.get());
69 | } else {
70 | return this.user;
71 | }
72 | }
73 | }
74 |
75 | }
--------------------------------------------------------------------------------
/stork-deploy/src/main/java/com/fizzed/stork/deploy/DeploymentType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.deploy;
17 |
18 | public enum DeploymentType {
19 |
20 | FRESH,
21 | UPGRADE
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/stork-deploy/src/main/java/com/fizzed/stork/deploy/ExistingDeployment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.deploy;
17 |
18 | import java.util.Optional;
19 | import java.util.SortedSet;
20 |
21 | public class ExistingDeployment extends Deployment {
22 |
23 | private final Long deployedAt;
24 | private final SortedSet versionDirs;
25 | private final Optional retain;
26 |
27 | public ExistingDeployment(String baseDir, String currentDir, String versionDir, String user, String group, Long deployedAt, SortedSet versionDirs, Optional retain) {
28 | super(baseDir, currentDir, versionDir, user, group);
29 | this.versionDirs = versionDirs;
30 | this.deployedAt = deployedAt;
31 | this.retain = retain;
32 | }
33 |
34 | public Long getDeployedAt() {
35 | return deployedAt;
36 | }
37 |
38 | public SortedSet getVersionDirs() {
39 | return versionDirs;
40 | }
41 |
42 | public boolean isFresh() {
43 | return getCurrentDir() == null;
44 | }
45 |
46 | public boolean isUpgrade() {
47 | return getCurrentDir() != null;
48 | }
49 |
50 | public Optional getRetain() {
51 | return retain;
52 | }
53 |
54 | }
--------------------------------------------------------------------------------
/stork-deploy/src/main/java/com/fizzed/stork/deploy/InitType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.deploy;
17 |
18 | public enum InitType {
19 |
20 | UNKNOWN,
21 | SYSV,
22 | SYSTEMD,
23 | UPSTART
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/stork-deploy/src/main/java/com/fizzed/stork/deploy/SshTarget.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Fizzed, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.fizzed.stork.deploy;
17 |
18 | import com.fizzed.blaze.SecureShells;
19 | import com.fizzed.blaze.ssh.SshExec;
20 | import com.fizzed.blaze.ssh.SshSession;
21 | import java.util.ArrayDeque;
22 | import java.util.Arrays;
23 | import java.util.Deque;
24 | import org.slf4j.Logger;
25 | import org.slf4j.LoggerFactory;
26 | import com.fizzed.blaze.ssh.SshSftpSession;
27 | import java.io.IOException;
28 | import java.util.Map;
29 |
30 | abstract public class SshTarget extends Target {
31 | static private final Logger log = LoggerFactory.getLogger(SshTarget.class);
32 |
33 | protected final SshSession ssh;
34 | protected final SshSftpSession sftp;
35 | protected final Map commands;
36 |
37 | public SshTarget(SshSession ssh, SshSftpSession sftp, String uname, InitType initType, String tempDir, Map commands) {
38 | super(ssh.uri(), uname, initType, tempDir);
39 | this.ssh = ssh;
40 | this.sftp = sftp;
41 | this.commands = commands;
42 | }
43 |
44 | public SshExec sshExec(boolean sudo, boolean shell, Object... args) {
45 | Deque