Class: Philae::DockerProbe

Inherits:
Object
  • Object
show all
Defined in:
lib/philae/docker_probe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, endpoint = '/var/run/docker.sock', options = {}) ⇒ DockerProbe

Returns a new instance of DockerProbe.



7
8
9
10
11
# File 'lib/philae/docker_probe.rb', line 7

def initialize(name, endpoint = '/var/run/docker.sock', options = {})
  @name = name
  @endpoint = endpoint
  @docker_options = {read_timeout: 50, connect_timeout: 50}.merge(options)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/philae/docker_probe.rb', line 5

def name
  @name
end

Instance Method Details

#checkObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/philae/docker_probe.rb', line 13

def check
  Docker.url = @endpoint
  Docker.options = @docker_options
  begin
    Docker::Container.all
  rescue => e
    return { healthy: false, comment: "Unable to communicate with docker (#{e.message})" }
  end

  return { healthy: true, comment: '' }
end