Class: VagrantPlugins::ProviderLocal::Action::Shutdown
- Inherits:
-
Object
- Object
- VagrantPlugins::ProviderLocal::Action::Shutdown
- Includes:
- Vagrant::Util::Retryable
- Defined in:
- lib/vagrant-local/action/shutdown.rb
Overview
This is used to shutdown the instance
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, _env) ⇒ Shutdown
constructor
A new instance of Shutdown.
Constructor Details
#initialize(app, _env) ⇒ Shutdown
Returns a new instance of Shutdown.
13 14 15 16 |
# File 'lib/vagrant-local/action/shutdown.rb', line 13 def initialize(app, _env) @logger = Log4r::Logger.new('vagrant_local::action::shutdown') @app = app end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vagrant-local/action/shutdown.rb', line 18 def call(env) @machine = env[:machine] @driver = @machine.provider.driver ui = env[:ui] ui.info(I18n.t('vagrant_local.graceful_shutdown_started')) @driver.control(ui, 'shutdown') env[:metrics] ||= {} env[:metrics]['instance_ssh_time'] = Util::Timer.time do retryable(on: Errors::TimeoutError, tries: 300) do # If we're interrupted don't worry about waiting break if env[:interrupted] break unless env[:machine].communicate.ready? end end env[:metrics]['instance_ssh_time'] = Util::Timer.time do 300.times do ui.info(I18n.t('vagrant_local.graceful_shutdown_complete')) unless @driver.state == :running sleep 1 if @driver.state == :running break unless @driver.state == :running break if env[:interrupted] end end @driver.halt(env[:ui]) @app.call(env) end |