2

I have a Gradle based Java application. The app is actually a daemon. On my local box, I can start the daemon by running:

> gradle run

That works great, but what I need is a way to kick off the daemon when the host is rebooted. I'm trying to get this to work on an EC2 instance.

AlexG
  • 1,596
  • 2
  • 17
  • 26

2 Answers2

2

I'm working on a plugin to do just this. The primary components are to generate init.d scripts, another component is to package them into a DEB or RPM. I haven't tied it with the application plugin itself just yet, but it's close, it's called the nebula-ospackage-daemon plugin: https://github.com/nebula-plugins/nebula-ospackage-plugin#nebula-ospackage-daemon. You would do something like:

 buildscript {
    repositories { jcenter() }

    dependencies {
        classpath 'com.netflix.nebula:nebula-ospackage-plugin:1.12.+'
    }
}

apply plugin: 'application'
mainClassName = "sample.Main"

apply plugin: 'os-package'
apply plugin: 'nebula-ospackage-daemon'

daemon {
    command = "/opt/myapp/bin/ospackage-application"
}

ospackage {
    into('/opt/myapp')
    with(applicationDistribution)
}
Justin Ryan
  • 2,413
  • 1
  • 15
  • 5
1

I was looking for something similar.

Perhaps you may want to look at the following Gradle plugin that is similar to Gradle application plugin but also installs app as init.d service.

A different solution (simple script) is proposed here.

Community
  • 1
  • 1
Andy Malakov
  • 797
  • 8
  • 6