class SignalHandler

Singleton class used to intercept signals. If a SIGINT or SIGTERM is received a message is outputted and @should_quit is set to true

Attributes

should_quit[R]

Public Class Methods

new() click to toggle source
# File lib/signal_handler.rb, line 14
def initialize
  @should_quit = false
  Signal.trap("SIGINT") { handle_signal }
  Signal.trap("SIGTERM") { handle_signal }
end

Public Instance Methods

handle_signal() click to toggle source
# File lib/signal_handler.rb, line 9
def handle_signal
  puts "PID #{Process.pid} is gracefully shutting down..."
  @should_quit = true
end