Sha256: 1ea179e513191bec28308d08afd33c1a3911b03ec85cfb8f7d9a03f9fd665b9d
Contents?: true
Size: 1.05 KB
Versions: 6
Compression:
Stored size: 1.05 KB
Contents
module Resque class Pool class Killer include Logging GRACEFUL_SHUTDOWN_SIGNAL=:INT def self.run new.run end 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 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 RESQUE_POOL_PIDS = / ^\s*(\d+) # PID digits, optional leading spaces \s+ # column divider #{Regexp.escape(PROCLINE_PREFIX)} # exact match at start of command /x def parse_pids_from_output(output) output.scan(RESQUE_POOL_PIDS).flatten.map(&:to_i) end end end end
Version data entries
6 entries across 6 versions & 2 rubygems