/shell-sysd-notify-watchdog

Send watchdog notifications to systemd using /usr/bin/systemd-notify

Primary LanguageJavaApache License 2.0Apache-2.0

Send watchdog notifications to systemd

Lib for java daemons to send keep-alive messages to refresh the systemd watchdog timestamp using the shell utility /usr/bin/systemd-notify. Or you can use this project to do it natively.

Use the version 1.1 build artifact.

	<groupId>org.tricorder</groupId>
	<artifactId>shell-sysd-notify-watchdog</artifactId>
	<version>1.1</version>

Simple Usage

	SysDNotifier() notifier = new SysDNotifier();
 	notifier.start();

Advanced Usage

	SysDNotifier notifier = new SysDNotifier();
	notifier.setAuditor(new Auditor() {
		@Override
		public boolean allGood() {				
			//Do more extensive internal checking of the process, if ok, return true.
			//Returning false will have the effect of suppressing the keep-alive 
			//message, causing systemd to kill and restart the process. 
			return true;
		}
	});
	notifier.start();

.service file layout

[Unit]
Description=My Service

[Service]
#PIDFile=/tmp/my-service.pid
ExecStart=/usr/lib/jvm/java-1.8.0/bin/java -jar /tmp/my-service.jar
WatchdogSec=120
Restart=on-failure
Environment=FILELOC=/usr/bin/systemd-notify
NotifyAccess=all
StartLimitInterval=2min
StartLimitBurst=4
StartLimitAction=none

[Install]
WantedBy=multi-user.target