module AutoConsul::Runner
Constants
- INITIAL_VERIFY_SLEEP
- RETRIES
- SLEEP_INTERVAL
Public Class Methods
agent_runner(identity, bind_ip, expiry, local_state, registry, opt={})
click to toggle source
# File lib/auto-consul/runner.rb, line 162 def self.agent_runner identity, bind_ip, expiry, local_state, registry, opt={} opt[:remote_ip] = pick_joining_host(registry.agents.members(expiry)) args = ['-bind', bind_ip, '-data-dir', local_state.data_path, '-node', identity] args += ['-config-dir', opt[:config_dir]] if ! opt[:config_dir].nil? joining_runner(args, opt) end
join(remote_ip)
click to toggle source
# File lib/auto-consul/runner.rb, line 153 def self.join remote_ip system('consul', 'join', remote_ip) end
joining_runner(agent_args, opt={})
click to toggle source
# File lib/auto-consul/runner.rb, line 135 def self.joining_runner(agent_args, opt={}) opt_args = [] opt_args += ['-advertise', opt[:advertise]] if ! opt[:advertise].nil? runner = AgentProcess.new(agent_args + opt_args) if not opt[:remote_ip].nil? runner.on_up {|a| join opt[:remote_ip]} end runner end
pick_joining_host(hosts)
click to toggle source
# File lib/auto-consul/runner.rb, line 157 def self.pick_joining_host hosts # Lets randomize this later. hosts[0].data end
server_runner(identity, bind_ip, expiry, local_state, registry, opt={})
click to toggle source
# File lib/auto-consul/runner.rb, line 169 def self.server_runner identity, bind_ip, expiry, local_state, registry, opt={} members = registry.servers.members(expiry) opt[:remote_ip] = members.size > 0 ? pick_joining_host(members) : nil args = ['-bind', bind_ip, '-data-dir', local_state.data_path, '-node', identity, '-server'] args += ['-config-dir', opt[:config_dir]] if ! opt[:config_dir].nil? args << '-bootstrap' if members.size < 1 joining_runner(args, opt) end
verify_running(pid)
click to toggle source
# File lib/auto-consul/runner.rb, line 145 def self.verify_running pid RETRIES.times do |i| sleep SLEEP_INTERVAL + (SLEEP_INTERVAL * i) return true if system('consul', 'info') end return false end