lib/minke/docker/health_check.rb in minke-1.12.9 vs lib/minke/docker/health_check.rb in minke-1.13.0
- old
+ new
@@ -2,25 +2,26 @@
module Docker
##
# HealthCheck checks health of a running container
class HealthCheck
- def initialize count=nil, pause=nil
+ def initialize logger, count=nil, pause=nil
@count = count ||= 180
@pause = pause ||= 1
@successes = 2
+ @logger = logger
end
##
# waits until a 200 response is received from the given url
def wait_for_HTTPOK url
- puts "Waiting for server #{url} to start #{@count} attempts left"
+ @logger.debug "Waiting for server #{url} to start #{@count} attempts left"
begin
response = RestClient.send('get', url)
rescue
- puts 'Invalid response from server'
+ @logger.error 'Invalid response from server'
end
check_response response, url
end
@@ -44,16 +45,16 @@
end
end
def check_success url
if @successes > 0
- puts "Server: #{url} passed health check, #{@successes} checks to go..."
+ @logger.debug "Server: #{url} passed health check, #{@successes} checks to go..."
@successes -= 1
sleep @pause
wait_for_HTTPOK url
else
- puts "Server: #{url} healthy"
+ @logger.debug "Server: #{url} healthy"
end
end
end
end