Sha256: 335666dbcf98cba82d424d6b10713e76b1506b11ab9daa8e680ab323aad00173

Contents?: true

Size: 1.72 KB

Versions: 39

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

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

    return false unless command_available_else_error? config.active['cmd_mutagen_check']

    # Are we inside a takelage container?
    unless _docker_container_lib_check_matrjoschka
      unless _file_exists? config.active['mutagen_socket_path_mutagen_host']
        log.error 'The mutagen socket path on the host is not available'
        return false
      end

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

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

    unless _file_exists? config.active['mutagen_socket_path_mutagen_container']
      log.error 'The mutagen socket path in the container is not available'
      return false
    end

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

  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
    )
    stdout, _, exitstatus = run_and_capture check_host_connection

    unless exitstatus.zero?
      log.debug 'There is no mutagen forward connection to the host'
      return false
    end

    unless stdout.include? 'Status: Forwarding'
      log.debug 'The mutagen forward connection to the host ' \
                'is not forwarding connections'
      return false
    end

    true
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
takeltau-0.45.8 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.45.6 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.45.5 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.45.4 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.45.3 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.45.2 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.45.0 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.44.42 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.44.41 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.44.39 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.44.37 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.44.36 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.44.35 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.44.29 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.44.27 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.44.24 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.44.23 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.44.19 lib/takeltau/mutagen/check/daemon.rb
takeltau-0.44.18 lib/takeltau/mutagen/check/daemon.rb