Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gchauvet/satellite

Satellite Toolkit
https://github.com/gchauvet/satellite

background-process daemon java linux service windows

Last synced: 16 days ago
JSON representation

Satellite Toolkit

Awesome Lists containing this project

README

        



# Satellite Toolkit
Satellite is a set of utilities and Java support classes for running Java applications as server processes.
Commonly known as 'daemon' processes in Unix terminology, on Windows they are called 'services'.

[![Build Status](https://travis-ci.org/gchauvet/satellite.png)](https://travis-ci.org/gchauvet/satellite)
[![Coverage Status](https://coveralls.io/repos/github/gchauvet/satellite/badge.svg?branch=master)](https://coveralls.io/github/gchauvet/satellite?branch=master)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.zatarox.satellite/satellite-api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.zatarox.satellite/satellite-api)

## Requirements
Compilation process is performed under Linux. Cross-compilation fanboy :-)

* Gradle 4.4.x
* Java Development Kit >= 7
* Clang 5.x
* mingw-w64-x86-64-dev (gcc 5.x)
* libc6-dev-i386

## Satellite in action
Writing an independent OS background process become pretty simple. The first step is to implement a java interface who manage background process behaviors. The second step require `Phobos` or `Deimos` depending if you are under Windows or Linux. The Daemon behavior has been designed as the same manner as Windows service. Under Windows, only certain service state transitions are valid. The following diagram shows the valid transitions (credits to Microsoft) :



### Dependency
In your project, add the Satellite API dependency (Maven POM):

```xml

io.zatarox.satellite
satellite-api
1.0.0-SNAPSHOT
provided

```

### Core of the background process
This is the facade of your service. Attention : calls on these methods are synchronous.

```java
import io.zatarox.satellite.*;

public final class FooBackgroundProcess implements BackgroundProcess {

@Override
public void initialize(BackgroundContext dc) throws BackgroundException, Exception {
System.err.println("Initialized");
}

@Override
public void resume() throws Exception {
System.err.println("Started...");
}

@Override
public void pause() throws Exception {
System.err.println("Stopped !");
}

@Override
public void shutdown() {
System.err.println("Destroyed");
}
}
```

### Main jar assembly

Finally, add a manifest entry in your main jar (and dependency jars OFC).
```xml

maven-jar-plugin
3.0.2


true

io.zatarox.satellite.FooBackgroundProcess


```

### Sample
To a look to the sample project submodule to see how to get binary frontends from Gradle

## Inspiration
This project is based on Apache Commons Daemon.