Created
December 20, 2012 20:04
-
-
Save DAddYE/4348131 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
if ARGV[0] | |
signal = | |
case ARGV[0] | |
when 'wait' then :USR1 | |
when 'restart' then :USR2 | |
end | |
Process.kill(signal, ARGV[1].to_i) | |
exit 1 | |
end | |
trap :USR1 do | |
puts 'We will wait bye bye' | |
@wait = true | |
end | |
trap :USR2 do | |
puts 'Ok, restart broooo' | |
@wait = false | |
end | |
while true | |
sleep 1 while @wait | |
@wait = false | |
puts 'Long process with pid %d' % Process.pid | |
sleep 1 while true and not @wait | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment