Class: Rabbitek::CLI::SignalHandlers

Inherits:
Object
  • Object
show all
Defined in:
lib/rabbitek/cli/signal_handlers.rb

Overview

OS signal handlers

Constant Summary collapse

SIGNALS =
{
  INT: :shutdown,
  TERM: :shutdown
}.freeze

Class Method Summary collapse

Class Method Details

.setup(io_w) ⇒ Object



13
14
15
16
17
# File 'lib/rabbitek/cli/signal_handlers.rb', line 13

def self.setup(io_w)
  SIGNALS.each do |signal, hook|
    Signal.trap(signal) { io_w.write("#{hook}\n") }
  end
end

.shutdownObject

Raises:

  • (Interrupt)


19
20
21
# File 'lib/rabbitek/cli/signal_handlers.rb', line 19

def self.shutdown
  raise Interrupt
end