A pure Ruby implementation of systemd's sd_notify(3)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib Implement SdNotify.watchdog? May 18, 2018
.gitignore
CHANGELOG.md
LICENSE
README.md
sd_notify.gemspec

README.md

ruby-sdnotify

Gem Version Documentation License

A pure Ruby implementation of sd_notify(3) that can be used to communicate state changes of Ruby programs to systemd.

Refer to the API documentation for more info.

Getting started

Install ruby-sdnotify:

$ gem install sd_notify

If you're using Bundler, add it to your Gemfile:

gem "sd_notify"

and run bundle install

Usage

The API is mostly tied to the official implementation, therefore refer to the sd_notify(3) man pages for detailed description of how the notification mechanism works.

An example (assuming the program shipped as a systemd service):

require "sd_notify"

puts "Hello. Booting..."
sleep 2 # do some initialization work ...

SdNotify.ready

sum = 0
5.times do |i|
  sleep 1 # perform some work
  sum += 1
  SdNotify.status("{sum} jobs completed")
end

puts "Finished working, shutting down..."
SdNotify.stopping
sleep 2 # do cleanup work...

puts "Bye"

License

ruby-sdnotify is licensed under MIT. See LICENSE.