Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/agis/ruby-sdnotify
A pure-Ruby implementation of systemd's sd_notify(3)
https://github.com/agis/ruby-sdnotify
ruby ruby-sdnotify sd-notify sdnotify systemd systemd-service-notification watchdog
Last synced: 22 days ago
JSON representation
A pure-Ruby implementation of systemd's sd_notify(3)
- Host: GitHub
- URL: https://github.com/agis/ruby-sdnotify
- Owner: agis
- License: mit
- Created: 2017-09-09T22:36:59.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-26T22:56:22.000Z (4 months ago)
- Last Synced: 2024-10-06T04:14:22.660Z (about 1 month ago)
- Topics: ruby, ruby-sdnotify, sd-notify, sdnotify, systemd, systemd-service-notification, watchdog
- Language: Ruby
- Homepage: https://www.freedesktop.org/software/systemd/man/sd_notify.html
- Size: 27.3 KB
- Stars: 50
- Watchers: 5
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ruby-sdnotify
[![Gem Version](https://badge.fury.io/rb/sd_notify.svg)](https://badge.fury.io/rb/sd_notify)
[![Build status](https://github.com/agis/ruby-sdnotify/actions/workflows/ci.yml/badge.svg)](https://github.com/agis/ruby-sdnotify/actions/workflows/ci.yml)
[![Documentation](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/agis/ruby-sdnotify)
[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](LICENSE)A pure-Ruby implementation of [sd_notify(3)](https://www.freedesktop.org/software/systemd/man/sd_notify.html) that can be used to
communicate state changes of Ruby programs to [systemd](https://www.freedesktop.org/wiki/Software/systemd/).Refer to the [API documentation](http://www.rubydoc.info/github/agis/ruby-sdnotify) for more info.
## Getting started
Install ruby-sdnotify:
```shell
$ gem install sd_notify
```If you're using Bundler, add it to your Gemfile:
```ruby
gem "sd_notify"
```## Usage
The [API](http://www.rubydoc.info/github/agis/ruby-sdnotify) is mostly tied to
the official implementation, therefore refer to the [sd_notify(3) man pages](https://www.freedesktop.org/software/systemd/man/sd_notify.html)
for detailed description of how the notification mechanism works.An example involving a dummy workload (assuming the program is shipped as a
systemd service):```ruby
require "sd_notify"puts "Hello! Booting..."
# doing some initialization work...
sleep 2# notify systemd that we're ready
SdNotify.readysum = 0
5.times do |i|
# doing our main work...
sleep 1sum += 1
# notify systemd of our progress
SdNotify.status("{sum} jobs completed")
endputs "Finished working. Shutting down..."
# notify systemd we're shutting down
SdNotify.stopping# doing some cleanup work...
sleep 2puts "Bye"
```## License
ruby-sdnotify is licensed under MIT. See [LICENSE](LICENSE).