Class: Vagrant::LXC::Action::ClearForwardedPorts

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-lxc/action/clear_forwarded_ports.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ClearForwardedPorts

Returns a new instance of ClearForwardedPorts.



5
6
7
8
# File 'lib/vagrant-lxc/action/clear_forwarded_ports.rb', line 5

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new("vagrant::lxc::action::clear_forwarded_ports")
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vagrant-lxc/action/clear_forwarded_ports.rb', line 10

def call(env)
  @env = env

  if redir_pids.any?
    env[:ui].info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting")
    redir_pids.each do |pid|
      next unless is_redir_pid?(pid)
      @logger.debug "Killing pid #{pid}"
      system "pkill -TERM -P #{pid}"
    end

    remove_redir_pids
  end

  @app.call env
end