Class: Bosh::Deployer::Registry
- Inherits:
-
Object
- Object
- Bosh::Deployer::Registry
- Defined in:
- lib/bosh/deployer/registry.rb
Constant Summary collapse
- RETRYABLE_HTTP_EXCEPTIONS =
[ URI::Error, SocketError, Errno::ECONNREFUSED, HTTPClient::ReceiveTimeoutError ]
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(endpoint, cloud_plugin, cloud_properties, state, logger) ⇒ Registry
constructor
A new instance of Registry.
- #start ⇒ Object
- #stop ⇒ Object
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
#port ⇒ Object (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
#start ⇒ Object
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 |
#stop ⇒ Object
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 |