Class: Bosh::Deployer::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/deployer/registry.rb

Constant Summary collapse

RETRYABLE_HTTP_EXCEPTIONS =
[
  URI::Error,
  SocketError,
  Errno::ECONNREFUSED,
  HTTPClient::ReceiveTimeoutError
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, cloud_plugin, cloud_properties, state, logger) ⇒ Registry

Returns a new instance of Registry.



8
9
10
11
12
13
14
15
16
17
# File 'lib/bosh/deployer/registry.rb', line 8

def initialize(endpoint, cloud_plugin, cloud_properties, state, logger)
  @cloud_properties = cloud_properties
  @state = state
  @logger = logger

  uri = URI.parse(endpoint)
  @user, @password = uri.userinfo.split(':', 2)
  @port = uri.port
  @cloud_plugin = cloud_plugin
end

Instance Attribute Details

#portObject (readonly)

Returns the value of attribute port.



6
7
8
# File 'lib/bosh/deployer/registry.rb', line 6

def port
  @port
end

Instance Method Details

#startObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bosh/deployer/registry.rb', line 19

def start
  write_configure
  Sequel.connect(connection_settings) do |db|
    migrate(db)
    instances = state.deployments['registry_instances']
    db[:registry_instances].multi_insert(instances) if instances
  end

  unless has_bosh_registry?
    err "bosh-registry command not found - run 'gem install bosh-registry'"
  end

  cmd = "bosh-registry -c #{@registry_config.path}"

  @registry_pid = Process.spawn(cmd)

  watch_for_crash(cmd)
  wait_for_listen

  logger.info("bosh-registry is ready on port #{port}")
ensure
  @registry_config.unlink if @registry_config
end

#stopObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/bosh/deployer/registry.rb', line 43

def stop
  kill_registry if registry_pid

  return unless db_file

  Sequel.connect(connection_settings) do |db|
    state.deployments['registry_instances'] = db[:registry_instances].map { |row| row }
  end
ensure
  db_file.unlink if db_file
end