Sha256: b056a5116a61dba228e001660623a1811d9fbc5c0a3d6dd4d3fa9e19f1abc959

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

# takelage info status mutagen
module MutagenCheckDaemon
  # Backend method for mutagen check daemon.
  # @return [Boolean] is mutagen available?
  # rubocop:disable Metrics/MethodLength
  # rubocop:disable Metrics/AbcSize
  def mutagen_check_daemon
    log.debug 'Check mutagen status'

    return false unless command_available? 'mutagen'

    # are we outside of a takelage container?
    unless _docker_container_lib_check_matrjoschka
      unless _mutagen_check_daemon_version
        log.error 'The mutagen daemon is not available'
        return false
      end

      log.debug 'The mutagen daemon is available'
      return true
    end

    unless _file_exists? config.active['mutagen_socket_path']
      log.error 'The mutagen socket is not available'
      return false
    end

    unless _mutagen_check_daemon_host_connection
      log.error 'A mutagen host connection is not available'
      return false
    end

    log.debug 'The mutagen daemon is available'
    true
  end
  # rubocop:enable Metrics/AbcSize
  # rubocop:enable Metrics/MethodLength

  private

  # Check mutagen host connection
  def _mutagen_check_daemon_host_connection
    check_host_connection = format(
      config.active['cmd_mutagen_check_daemon_host_connection'],
      hostlabel: @hostlabel
    )
    host_connection = try check_host_connection
    host_connection.exitstatus.zero?
  end

  # Check mutagen version
  def _mutagen_check_daemon_version
    version = try config.active['cmd_mutagen_check_daemon_version']
    version.exitstatus.zero?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
takelage-0.28.24 lib/takelage/mutagen/check/daemon.rb