Class: VagrantDNS::RestartMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-dns/restart_middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ RestartMiddleware

Returns a new instance of RestartMiddleware.



3
4
5
6
# File 'lib/vagrant-dns/restart_middleware.rb', line 3

def initialize(app, env)
  @app = app
  @env = env
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/vagrant-dns/restart_middleware.rb', line 8

def call(env)
  if VagrantDNS::Config.auto_run
    tmp_path = File.join(env[:vm].env.tmp_path, "dns")
    VagrantDNS::Configurator.new(env[:vm], tmp_path).run!
    VagrantDNS::Service.new(tmp_path).restart!
    env[:ui].info "Restarted DNS Service"
  end

  @app.call(env)
end