Class: Autosiege::CLI

Inherits:
Object
  • Object
show all
Includes:
Mixlib::CLI
Defined in:
lib/autosiege/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runObject



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/autosiege/cli.rb', line 46

def self.run
  cli = new
  begin
    cli.parse_options
  rescue OptionParser::InvalidOption
    puts cli.opt_parser
    exit 1
  end

  cli.run
end

Instance Method Details

#runObject



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/autosiege/cli.rb', line 58

def run
  if config[:setup]
    setup
    exit 0
  else
    ENV['SIEGE_LOGFILE'] = config[:logfile]
    cmd = "siege --concurrent=#{config[:concurrency]} --internet --time 1m --rc=#{config[:config_file]} --log --file=#{config[:urls_file]}"
    puts cmd
    system cmd
  end
end

#setupObject



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/autosiege/cli.rb', line 70

def setup
  system "mkdir -p log"
  system "touch log/siege.log"

  system "mkdir -p config/siege"
  siegefile = File.expand_path("../../../conf/siegerc", __FILE__)
  system "cp #{siegefile} config/siege/siegerc"

  urlsfile = File.expand_path("../../../conf/urls.txt", __FILE__)
  system "cp #{urlsfile} config/siege/urls.txt"
end