class Minke::Docker::Consul
Public Class Methods
new(args)
click to toggle source
# File lib/minke/docker/consul.rb, line 4 def initialize args @health_check = args[:health_check] @service_discovery = args[:service_discovery] @consul_loader = args[:consul_loader] @docker_runner = args[:docker_runner] @network = args[:network] @project_name = args[:project_name] @logger = args[:logger_helper] end
Public Instance Methods
start_and_load_data(consul_config)
click to toggle source
start_and_load_data
config
# File lib/minke/docker/consul.rb, line 16 def start_and_load_data consul_config @logger.info "Starting Consul" start wait_for_startup consul_config.url load_data consul_config.url, consul_config.config_file end
stop()
click to toggle source
stop consul
# File lib/minke/docker/consul.rb, line 25 def stop @logger.info "Stopping Consul" @docker_runner.stop_container @container unless @container == nil @docker_runner.delete_container @container unless @container == nil end
Private Instance Methods
load_data(url, config_file)
click to toggle source
Loads consul data into the given server
# File lib/minke/docker/consul.rb, line 52 def load_data url, config_file server = @service_discovery.build_address(url) @consul_loader.load_config config_file, server end
start()
click to toggle source
# File lib/minke/docker/consul.rb, line 32 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 } ) end
wait_for_startup(url)
click to toggle source
# File lib/minke/docker/consul.rb, line 45 def wait_for_startup url server = @service_discovery.build_address(url) @health_check.wait_for_HTTPOK "#{server}/v1/status/leader" end