Class: MinioRunner::MinioHealthCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/minio_runner/minio_health_check.rb

Overview

Checks that the minio server is running on the configured port using the /minio/health/live endpoint with a limited number of retries.

Also used to check whether /etc/hosts is configured properly; some platforms (read: macOS) have to be configured in a certain way to avoid this.

Class Method Summary collapse

Class Method Details

.call(retries: 2, initial_retries: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/minio_runner/minio_health_check.rb', line 12

def call(retries: 2, initial_retries: nil)
  initial_retries ||= retries
  begin
    Network.get("#{MinioRunner.config.minio_server_url}/minio/health/live")
  rescue StandardError, MinioRunner::Network::NetworkError
    if retries.positive?
      sleep 1
      call(retries: retries - 1, initial_retries: initial_retries)
    else
      message =
        "Minio server failed to start after #{initial_retries + 1} attempts. Check that /etc/hosts is configured properly."

      if MinioRunner::System.mac? && MinioRunner.config.minio_domain.end_with?(".local")
        message += "\n\n" + MinioRunner::Network::MAC_OS_LOCAL_DOMAIN_ERROR_MESSAGE
      end

      raise MinioRunner::Network::NetworkError.new(message)
    end
  end
end