Sha256: fc4fc7046a015e060f746e4e011a58c003139cf61ddc314e5e2d445c6489d214
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
#!/usr/bin/env ruby require 'optparse' require 'killsite' require 'memory_monitor' if `which ab`.empty? puts "ab (ApacheBench) must be installed to proceed" exit -1 end options = {} optparse = OptionParser.new do |opts| opts.on('-h', '--help', 'Show help message') do puts opts exit 0 end opts.on('-l', '--limit NUM', 'Setting the limit of a single test') do |limit| if limit.to_i > 0 options[:limit] = limit.to_i else puts "Limit must greater than 1" exit 1 end end opts.on('-c', '--concurrency NUM', 'Setting the number of concurrent connection') do |num| if num.to_i > 0 options[:concurrency] = num.to_i else puts "The number of concurrency must greater than 1" exit 2 end end opts.on('-p', '--pid PID', 'The PID is the monitored server process') do |pid| if pid.to_i > 0 and `ps -o pid #{pid}`.split.size > 1 options[:pid] = pid.to_i else puts "PID not exists or invalid" exit 3 end end end optparse.parse! options[:prefix] = ARGV.shift unless options[:prefix] puts "Please specify the URL" exit 4 end monitors = (options[:pid]) ? [MemoryMonitor.new(options[:pid])] : [] SiteKiller.new(options[:prefix], options[:limit], options[:concurrency], true, monitors).run monitors.each(&:report) unless monitors.empty?
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
killsite-0.3.0 | bin/killsite |