Sha256: c0bad33d5806d75c558e436cf97cd6b10259383f448ea06a4756636beb055c3b
Contents?: true
Size: 989 Bytes
Versions: 12
Compression:
Stored size: 989 Bytes
Contents
class Eye::Checker::ChildrenCount < Eye::Checker::Measure # check :children_count, :every => 30.seconds, :below => 10, :strategy => :kill_old # monitor_children should be enabled param :strategy, Symbol, nil, :restart, [:restart, :kill_old, :kill_new] def get_value process.children.size end def fire if strategy == :restart super else pids = ordered_by_date_children_pids pids = if strategy == :kill_old pids[0...-below] else pids[below..-1] end kill_pids(pids) end end private def kill_pids(pids) info "killing pids: #{pids.inspect} for strategy: #{strategy}" pids.each do |pid| if child = process.children[pid] child.schedule :stop, Eye::Reason.new("bounded #{check_name}") end end end def ordered_by_date_children_pids children = process.children.values children.sort_by { |ch| Eye::SystemResources.start_time(ch.pid).to_i }.map &:pid end end
Version data entries
12 entries across 12 versions & 2 rubygems