Sha256: c15b6f92d02a422b3d640ee071d6ee6cc23b7efa4798efd7ae6a563ca739dfb9

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

#!/usr/bin/env ruby
require 'optparse'

$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
require 'zombie_passenger_killer'

options = {}
version = ZombiePassengerKiller::VERSION
OptionParser.new do |opts|
  opts.banner = <<BANNER
Guaranteed zombie passengers death

Usage:
    zombie_passenger_killer [options]

Options:
BANNER
  opts.on("-m", "--max [SIZE]", Integer, "Max high CPU entries in history before killing (default: off)") {|i| options[:max]=i }
  opts.on("--history [SIZE]", Integer, "History size (default: 5)") {|i| options[:history]=i }
  opts.on("-c", "--cpu [PERCENT]", Integer, "Mark as high CPU when above PERCENT (default: 70)") {|i| options[:cpu]=i }
  opts.on("-g", "--grace [SECONDS]", Integer, "Wait SECONDS before hard-killing (-9) a process (default: 5)") {|i| options[:grace]=i }
  opts.on("-i", "--interval [SECONDS]", Integer, "Check every SECONDS (default: 10)") {|i| options[:interval]=i }
  opts.on("-p", "--pattern [PATTERN]", String, "Find processes with this pattern (default: ' Rack: ')") {|i| options[:pattern]=i }
  opts.on("-1", "--once", "Check once and exit") { options[:once]=true }
  opts.on("--rvmsudo", "Use `rvmsudo` to see passenger-status") { options[:rvmsudo]=true }
  opts.on("-h", "--help","Show this") { puts opts; exit }
  opts.on("-v", "--version","Show Version"){ puts version; exit }
  opts.on("-t", "--timing","Show timing on output") { options[:show_times]=true }
end.parse!

$stdout.sync = true
puts "PID: #{$$} Version: #{version} Started at #{Time.now}"

$0 = File.basename(__FILE__) + '-' + version

method = (options[:once] ? :hunt_zombies : :lurk)
ZombiePassengerKiller::Reaper.new(options).send(method)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zombie_passenger_killer-0.3.0 bin/zombie_passenger_killer
zombie_passenger_killer-0.2.5 bin/zombie_passenger_killer
zombie_passenger_killer-0.2.4 bin/zombie_passenger_killer
zombie_passenger_killer-0.2.3 bin/zombie_passenger_killer