Class: LoadManager
- Inherits:
-
Object
- Object
- LoadManager
- Defined in:
- lib/load/load_manager.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#run_id ⇒ Object
readonly
Returns the value of attribute run_id.
Instance Method Summary collapse
-
#initialize(configuration, target_code) ⇒ LoadManager
constructor
A new instance of LoadManager.
- #kill_pids(pids) ⇒ Object
- #ramp_up ⇒ Object
Constructor Details
#initialize(configuration, target_code) ⇒ LoadManager
Returns a new instance of LoadManager.
10 11 12 |
# File 'lib/load/load_manager.rb', line 10 def initialize(configuration, target_code) @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
8 9 10 |
# File 'lib/load/load_manager.rb', line 8 def configuration @configuration end |
#run_id ⇒ Object (readonly)
Returns the value of attribute run_id.
8 9 10 |
# File 'lib/load/load_manager.rb', line 8 def run_id @run_id end |
Instance Method Details
#kill_pids(pids) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/load/load_manager.rb', line 65 def kill_pids(pids) puts "Killing child processes" pids.each do |pid| Process.kill("INT", pid) end end |
#ramp_up ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/load/load_manager.rb', line 14 def ramp_up puts "Load Manager - ramp_up" puts "Load Manager: #{Process.pid}" pids = [] definition_code = configuration['code'] @server_address = ENV["SERVER"] || "localhost:2233" puts "Server address: #{@server_address}" if (ENV['SERVER'] == nil) puts "No 'SERVER' env specified, creating local/minimal server to store results" pids << fork { @reporter = LoadReporter.new({server: @server_address}) while (@reporter.started == false) puts "Cannot find Load server" sleep 1 end } else puts "Using existent 'SERVER': #{@server_address}" end @run_id = create_run({definition_code: definition_code}) ramp_up = LoadRampUp.new(@run_id, @target_code, @configuration) pids << fork { ramp_up.run } quit = false while !quit begin system("stty raw -echo") str = STDIN.getc ensure system("stty -raw echo") end input = str.chr puts "You pressed: #{input} ##{str.to_i}" if (input == "q") quit = true puts "==================================================================================" puts "DONE WITH RAMP UP" puts " PID's: #{pids}" puts "==================================================================================" end end kill_pids(pids) end |