Class: TestbotCloud::Cluster
- Inherits:
-
Object
- Object
- TestbotCloud::Cluster
- Defined in:
- lib/cluster.rb
Instance Method Summary collapse
-
#initialize ⇒ Cluster
constructor
A new instance of Cluster.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ Cluster
Returns a new instance of Cluster.
10 11 12 13 14 15 16 17 |
# File 'lib/cluster.rb', line 10 def initialize Fog.mock! if ENV['INTEGRATION_TEST'] if project? load_config @compute = Fog::Compute.new(@provider_config) end end |
Instance Method Details
#start ⇒ Object
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 |
# File 'lib/cluster.rb', line 19 def start project? || return puts "Starting #{@runner_count} runners..." for_each_runner_in_a_thread do |mutex| server = nil with_retries("server creation") do mutex.synchronize { server = @compute.servers.create(@runner_config) Servers.log_creation(server) } end puts "#{server.id} is being created..." with_retries("#{server.id} ready check") do server.wait_for { ready? } end puts "#{server.id} is up, installing testbot..." with_retries("testbot installation") do if Server::Factory.create(@compute, @opts, server).bootstrap!(mutex) puts "#{server.id} ready." else puts "#{server.id} failed, shutting down." server.destroy Servers.log_destruction(server) end end end end |
#stop ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cluster.rb', line 50 def stop project? || return @compute.servers.each do |server| if Servers.known?(server) && server.ready? puts "Shutting down #{server.id}..." with_retries("server destruction") do server.destroy end Servers.log_destruction(server) end end end |