Sha256: e7d9ed9d05edeea3b1ce7335c02576f63b415f677851153b695ba687e288a754
Contents?: true
Size: 477 Bytes
Versions: 2
Compression:
Stored size: 477 Bytes
Contents
require 'singleton' #Singleton class used to intercept signals. If a SIGINT or SIGTERM is received a message is outputted and @should_quit #is set to true class SignalHandler include Singleton attr_reader :should_quit def handle_signal puts "PID #{Process.pid} is gracefully shutting down..." @should_quit = true end def initialize @should_quit = false Signal.trap("SIGINT") { handle_signal } Signal.trap("SIGTERM") { handle_signal } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mogbak-0.2.1 | lib/signal_handler.rb |
mogbak-0.2.0 | lib/signal_handler.rb |