Class: Bigrig::Waiter

Inherits:
Object
  • Object
show all
Defined in:
lib/bigrig/waiter.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Waiter

Returns a new instance of Waiter.



3
4
5
# File 'lib/bigrig/waiter.rb', line 3

def initialize(name)
  @name = name
end

Instance Method Details

#script_present?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/bigrig/waiter.rb', line 14

def script_present?
  DockerAdapter.exec(@name, ['ls', '/bigrig-wait.sh'])[2] == 0
rescue Docker::Error::NotFoundError => e
  puts "Unable to determine if wait script is available: #{e}"
end

#wait_if_neededObject



7
8
9
10
11
12
# File 'lib/bigrig/waiter.rb', line 7

def wait_if_needed
  script_present? || return
  puts "Waiting for `/bigrig-wait.sh` to compelte on #{@name}"
  result = DockerAdapter.exec @name, '/bigrig-wait.sh'
  result[2] != 0 && fail("Error waiting for container: #{result.first.first}")
end