Class: KumoDockerCloud::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/kumo_dockercloud/service.rb

Instance Method Summary collapse

Constructor Details

#initialize(stack_name, service_name) ⇒ Service

Returns a new instance of Service.



5
6
7
8
# File 'lib/kumo_dockercloud/service.rb', line 5

def initialize(stack_name, service_name)
  @stack_name = stack_name
  @name = service_name
end

Instance Method Details

#check(checks, timeout) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/kumo_dockercloud/service.rb', line 15

def check(checks, timeout)
  Timeout::timeout(timeout) do
    all_tests_passed = true
    containers.each do |container|
      checks.each do |check|
        unless check.call(container)
          all_tests_passed = false
        end
      end
    end

    unless all_tests_passed
      print '.'
      sleep(5)
      check(checks, timeout)
    end

    true
  end
rescue
  raise KumoDockerCloud::ServiceDeployError.new("One or more checks failed to pass within the timeout")
end

#deploy(version) ⇒ Object



10
11
12
13
# File 'lib/kumo_dockercloud/service.rb', line 10

def deploy(version)
  update_image(version)
  redeploy
end