class Landrush::Action::Teardown

Public Instance Methods

call(env) click to toggle source
# File lib/landrush/action/teardown.rb, line 6
def call(env)
  # Make sure we use the right data directory for Landrush
  # Seems Vagrant only makes home_path available in this case, compared to custom commands where there is also data_dir
  Server.working_dir = File.join(env[:home_path], 'data', 'landrush')

  teardown if enabled?
  app.call(env)
end
teardown() click to toggle source
# File lib/landrush/action/teardown.rb, line 15
def teardown
  teardown_machine_dns
  DependentVMs.remove(machine_hostname)

  return unless DependentVMs.none?

  teardown_static_dns
  teardown_server
end
teardown_machine_dns() click to toggle source
# File lib/landrush/action/teardown.rb, line 25
def teardown_machine_dns
  return unless Store.hosts.has? machine_hostname

  info "Removing machine entry: #{machine_hostname}"
  Store.hosts.delete(machine_hostname)
end
teardown_server() click to toggle source
# File lib/landrush/action/teardown.rb, line 41
def teardown_server
  Server.stop
end
teardown_static_dns() click to toggle source
# File lib/landrush/action/teardown.rb, line 32
def teardown_static_dns
  config.hosts.each do |static_hostname|
    if Store.hosts.has? static_hostname
      info "removing static entry: #{static_hostname}"
      Store.hosts.delete static_hostname
    end
  end
end