class Resque::Pool::Killer

Constants

GRACEFUL_SHUTDOWN_SIGNAL
RESQUE_POOL_PIDS

Public Class Methods

run() click to toggle source
# File lib/resque/pool/killer.rb, line 8
def self.run
  new.run
end

Public Instance Methods

all_resque_pool_processes() click to toggle source
# File lib/resque/pool/killer.rb, line 23
def all_resque_pool_processes
  out = `ps -e -o pid= -o command= 2>&1`
  raise "Unable to identify other pools: #{out}" unless $?.success?
  parse_pids_from_output out
end
parse_pids_from_output(output) click to toggle source
# File lib/resque/pool/killer.rb, line 35
def parse_pids_from_output(output)
  output.scan(RESQUE_POOL_PIDS).flatten.map(&:to_i)
end
run() click to toggle source
# File lib/resque/pool/killer.rb, line 12
def run
  my_pid = Process.pid
  pool_pids = all_resque_pool_processes
  pids_to_kill = pool_pids.reject{|pid| pid == my_pid}
  pids_to_kill.each do |pid|
    log "Pool (#{my_pid}) in kill-others mode: killing pool with pid (#{pid})"
    Process.kill(GRACEFUL_SHUTDOWN_SIGNAL, pid)
  end
end