Skip to content

Instantly share code, notes, and snippets.

@DAddYE
Created December 20, 2012 20:04
Show Gist options
  • Save DAddYE/4348131 to your computer and use it in GitHub Desktop.
Save DAddYE/4348131 to your computer and use it in GitHub Desktop.
#!/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