Sha256: 8a24b8c380c17d9f56038a464f21b3e93b956892b82fdcf314aa651d9e8b1a34

Contents?: true

Size: 1.63 KB

Versions: 15

Compression:

Stored size: 1.63 KB

Contents

module Minke
  module Docker
    class Consul
      def initialize health_check, service_discovery, consul_loader, docker_runner, network, project_name
        @health_check = health_check
        @service_discovery = service_discovery
        @consul_loader = consul_loader
        @docker_runner = docker_runner
        @network = network
        @project_name = project_name
      end

      ##
      # start_and_load_data config
      def start_and_load_data consul_config
        start
        wait_for_startup consul_config.url
        load_data consul_config.url, consul_config.config_file
      end

      ##
      # stop consul
      def stop
        @docker_runner.stop_container @container
        @docker_runner.delete_container @container
      end

      private
      def start
        @docker_runner.pull_image 'progrium/consul:latest' unless @docker_runner.find_image 'progrium/consul:latest'
        @container, success = @docker_runner.create_and_run_container(
          {
            :image   => 'progrium/consul',
            :network => @network,
            :command => '-server -bootstrap -ui-dir /ui',
            :name    => "/#{@project_name}_consul_1",
            :deamon  => true
          }
        )

        puts @container
      end
      
      def wait_for_startup url
        server = @service_discovery.build_address(url)
        @health_check.wait_for_HTTPOK "#{server}/v1/status/leader"
      end

      ##
      # Loads consul data into the given server
      def load_data url, config_file
        server = @service_discovery.build_address(url)
        @consul_loader.load_config config_file, server
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
minke-1.12.5 lib/minke/docker/consul.rb
minke-1.12.4 lib/minke/docker/consul.rb
minke-1.12.3 lib/minke/docker/consul.rb
minke-1.12.2 lib/minke/docker/consul.rb
minke-1.12.0 lib/minke/docker/consul.rb
minke-1.11.9 lib/minke/docker/consul.rb
minke-1.11.8 lib/minke/docker/consul.rb
minke-1.11.7 lib/minke/docker/consul.rb
minke-1.11.6 lib/minke/docker/consul.rb
minke-1.11.5 lib/minke/docker/consul.rb
minke-1.11.4 lib/minke/docker/consul.rb
minke-1.11.3 lib/minke/docker/consul.rb
minke-1.11.2 lib/minke/docker/consul.rb
minke-1.11.1 lib/minke/docker/consul.rb
minke-1.11.0 lib/minke/docker/consul.rb