All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pixonic.simplesystemdservice.Systemd Maven / Gradle / Ivy

The newest version!
package com.pixonic.simplesystemdservice;

import java.io.IOException;

public class Systemd {
    /**
     * Call this when your app is started.
     */
    public static void sendReady() {
        if (System.getenv("NOTIFY_SOCKET") == null) return;
        try {
            Process process = new ProcessBuilder("systemd-notify", "--ready")
                    .redirectOutput(ProcessBuilder.Redirect.INHERIT)
                    .redirectError(ProcessBuilder.Redirect.INHERIT)
                    .start();

            int exitCode = process.waitFor();
            if (exitCode != 0) {
                throw new RuntimeException("Can't notify systemd");
            }
        } catch (IOException | InterruptedException e) {
            throw new RuntimeException("Can't notify systemd", e);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy