class Object
Public Instance Methods
WithGracefulShutdown(*signals, &block)
click to toggle source
Catches INT
and TERM
and allows the task/program to finish execution before handling the interrupt safely.
Usage:
WithGracefulShutdown do begin loop do print '.' sleep 0.5 end rescue Shutdown => shutdown puts "\ngoodbye" shutdown.continue end end
# File lib/graceful_shutdown.rb, line 17 def WithGracefulShutdown(*signals, &block) GracefulShutdown.new.handle_signals(*signals, &block) end