sd_notify implementation for Java 17+ https://sdnotify.afoo.de
Find a file
Jan Hülsbergen 4754365f21
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
documentation fixes
2025-09-05 20:03:38 +02:00
gradle/wrapper drop Java 11 support, prepare 1.0 2025-09-05 18:47:50 +02:00
src documentation fixes 2025-09-05 20:03:38 +02:00
.gitignore .gitignore: broader ignore for IDEA files 2023-05-04 23:36:49 +02:00
.woodpecker.yml drop Java 11 support, prepare 1.0 2025-09-05 18:47:50 +02:00
build.gradle drop Java 11 support, prepare 1.0 2025-09-05 18:47:50 +02:00
gradlew drop Java 11 support, prepare 1.0 2025-09-05 18:47:50 +02:00
gradlew.bat drop Java 11 support, prepare 1.0 2025-09-05 18:47:50 +02:00
LICENSE docs, license 2022-10-15 17:24:31 +02:00
README.md documentation fixes 2025-09-05 20:03:38 +02:00
settings.gradle init 2022-09-22 23:11:23 +02:00

SDNotify

A simple library for Java 17+ implementing the sd_notify protocol from systemd.

<dependency>
    <groupId>de.afoo</groupId>
    <artifactId>sdnotify</artifactId>
    <version>1.0</version>
</dependency>
implementation 'de.afoo:sdnotify:1.0'

Usage

Create an instance using

SDNotify sdNotify = SDNotify.create();

This will either create an instance of ActualSDNotify or NOOPSDNotify depending on the availability of the sd_notify socket file. This means this library is usable safely whether you are running a service of Type=notify or not.

Once you have your instance, you can use it for communication between your service and systemd.

// tell systemd that your service is ready
sdNotify.ready();

// set status information for your service
sdNotify.status("currently running cleanup");

// inform systemd that your service is reloading
sdNotify.reloading();
  
// ... or stopping
sdNotify.stopping();

// Tell the watchdog, that your service is still available
// see https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#WatchdogSec=
sdNotify.watchdog();

For more comprehensive documentation, see here.