Created
June 13, 2019 05:42
-
-
Save carlosmn/221ceed54ab6a9210aa4c8d267e4adc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem "sd_notify" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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