Class: ConsulBridge::BootstrapConsul

Inherits:
Base
  • Object
show all
Defined in:
lib/consul_bridge/bootstrap_consul.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

call

Constructor Details

#initialize(bucket:, join_all: false) ⇒ BootstrapConsul

Returns a new instance of BootstrapConsul.



10
11
12
13
# File 'lib/consul_bridge/bootstrap_consul.rb', line 10

def initialize(bucket:, join_all: false)
  self.bucket = bucket
  self.join_all = join_all
end

Instance Attribute Details

#bucketObject

Returns the value of attribute bucket.



8
9
10
# File 'lib/consul_bridge/bootstrap_consul.rb', line 8

def bucket
  @bucket
end

#join_allObject

Returns the value of attribute join_all.



8
9
10
# File 'lib/consul_bridge/bootstrap_consul.rb', line 8

def join_all
  @join_all
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/consul_bridge/bootstrap_consul.rb', line 15

def call
  while !DetectConsul.call.running
    puts 'Local consul agent not detected, sleeping for 5 seconds'
    sleep 5
  end

  puts '==> Bootstrapping consul'
  master_ips = DownloadMasters.call(bucket: self.bucket).master_ips
  JoinConsul.call(master_ips: master_ips, join_all: self.join_all)
  puts '==> Done.'
end