class Resque::Plugins::WorkerKiller::PrivateMethods
Public Class Methods
new(obj)
click to toggle source
# File lib/resque/plugins/worker_killer.rb, line 37 def initialize(obj) @obj = obj end
Public Instance Methods
kill_self(logger, start_time)
click to toggle source
Kill the current process by telling it to send signals to itself If the process isn't killed after `@max_term` TERM signals, send a KILL signal.
# File lib/resque/plugins/worker_killer.rb, line 78 def kill_self(logger, start_time) alive_sec = (Time.now - start_time).round @@kill_attempts ||= 0 @@kill_attempts += 1 sig = :TERM sig = :KILL if @@kill_attempts > max_term logger.warn "#{plugin_name}: send SIG#{sig} (pid: #{Process.pid}) alive: #{alive_sec} sec (trial #{@@kill_attempts})" Process.kill(sig, Process.pid) end
monitor_oom()
click to toggle source
# File lib/resque/plugins/worker_killer.rb, line 58 def monitor_oom start_time = Time.now loop do one_shot_monitor_oom(start_time) sleep monitor_interval end end
one_shot_monitor_oom(start_time)
click to toggle source
# File lib/resque/plugins/worker_killer.rb, line 66 def one_shot_monitor_oom(start_time) rss = GetProcessMem.new.kb logger.info "#{plugin_name}: worker (pid: #{Process.pid}) using #{rss} KB." if verbose if rss > mem_limit logger.warn "#{plugin_name}: worker (pid: #{Process.pid}) exceeds memory limit (#{rss} KB > #{mem_limit} KB)" kill_self(logger, start_time) end end
plugin_name()
click to toggle source
# File lib/resque/plugins/worker_killer.rb, line 54 def plugin_name "Resque::Plugins::WorkerKiller" end