Skip to content

Instantly share code, notes, and snippets.

@carlosmn
Created June 13, 2019 05:42
Show Gist options
  • Save carlosmn/221ceed54ab6a9210aa4c8d267e4adc2 to your computer and use it in GitHub Desktop.
Save carlosmn/221ceed54ab6a9210aa4c8d267e4adc2 to your computer and use it in GitHub Desktop.
source 'https://rubygems.org'
gem "sd_notify"
#!/usr/bin/env ruby
# A test application to experiment with sd_notify from a ruby process
require "sd_notify"
# On startup, let's wait for 10s to give us a chance to look at the state of things
sleep 10
SdNotify.ready
# If we're asked to reload, pretend we're working for 10s so we have a chance to
# look at things here too
Signal.trap("HUP") do
SdNotify.reloading
sleep 10
SdNotify.ready
end
loop do
sleep 0.3
end
[Unit]
Description=A unit to experiment with services and sd_notify
[Service]
Type=notify
WorkingDirectory=/home/carlos/restartering/
ExecStart=bundle exec ruby restartering.rb
ExecReload=/bin/kill -HUP $MAINPID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment