Skip to content

ericbets/java-sysd-notify-watchdog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Send watchdog notifications to systemd

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

Use the version 1.1 build artifact.

	<groupId>org.tricorder</groupId>
	<artifactId>java-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
Environment=LD_PRELOAD=/usr/lib64/libsystemd-daemon.so
ExecStart=/usr/lib/jvm/java-1.8.0/bin/java -jar /usr/local/bin/my-service.jar
WatchdogSec=500
Restart=on-failure

[Install]
WantedBy=multi-user.target

About

Send watchdog notifications to systemd

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published