Class: GodUnmonitor

Inherits:
Watcher show all
Defined in:
lib/bender/watchers/god_unmonitor.rb

Instance Method Summary collapse

Methods inherited from Watcher

#initialize, #load_queue, #name, #publish, #start, #subscribe

Constructor Details

This class inherits a constructor from Watcher

Instance Method Details

#perform(message) ⇒ Object

Expects a message in the following format

:task_or_group_name => 'resque'


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bender/watchers/god_unmonitor.rb', line 7

def perform(message)
  task_or_group_name = message[:task_or_group_name]

  if task_or_group_name.nil?
    Bender.logger.warn("GodUnmonitor: task_or_group_name not defined - #{message}")
    return
  end

  Bender.logger.info("GodUnmonitor: #{task_or_group_name}")

  # TODO: sanitize input

  Open3.popen3("sudo god unmonitor #{task_or_group_name}") do |stdin, stdout, stderr, wait_thr|
    info = stdout.read
    error = stderr.read
    Bender.logger.info("GodUnmonitor: #{info.rstrip}") unless info.empty?
    Bender.logger.error("GodUnmonitor: #{error.rstrip}") unless error.empty?
  end

end