Class: Kuroko2::Command::Kill

Inherits:
Object
  • Object
show all
Defined in:
lib/autoload/kuroko2/command/kill.rb

Instance Method Summary collapse

Constructor Details

#initialize(host, process = nil) ⇒ Kill

Returns a new instance of Kill.



4
5
6
7
# File 'lib/autoload/kuroko2/command/kill.rb', line 4

def initialize(host, process = nil)
  @hostname = host
  @process  = process
end

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/autoload/kuroko2/command/kill.rb', line 9

def execute
  if (signal = ProcessSignal.poll(@hostname))
    Kuroko2.logger.info("[#{@hostname}-#{@process}] Send #{Signal.signame(signal.number)} signal to #{signal.pid}")
    Process.kill(signal.number, signal.pid)

    signal.destroy!
    signal
  end
rescue SystemCallError => e
  signal.update_column(:message, "[#{@hostname}-#{@process}] #{e.class}: #{e.message}") rescue nil

  Kuroko2.logger.error("[#{@hostname}-#{@process}] #{e.class}: #{e.message}")
end