Class: VagrantPlugins::Utm::Action::Boot
- Inherits:
-
Object
- Object
- VagrantPlugins::Utm::Action::Boot
- Defined in:
- lib/vagrant_utm/action/boot.rb
Overview
Action to start the virtual machine.
Instance Method Summary collapse
-
#call(env) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize(app, _env) ⇒ Boot
constructor
A new instance of Boot.
Constructor Details
#initialize(app, _env) ⇒ Boot
Returns a new instance of Boot.
8 9 10 |
# File 'lib/vagrant_utm/action/boot.rb', line 8 def initialize(app, _env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
rubocop:disable Metrics/AbcSize
12 13 14 15 16 17 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 43 |
# File 'lib/vagrant_utm/action/boot.rb', line 12 def call(env) # rubocop:disable Metrics/AbcSize # Start up the VM and wait for it to boot. env[:ui].info I18n.t("vagrant.actions.vm.boot.booting") # Wait for AppleScript configuration changes to be fully saved # before attempting to start the VM to avoid OSStatus error -609 # We retry the start command with exponential backoff if it fails max_retries = 3 retry_count = 0 retry_delay = 1 max_retries.times do env[:machine].provider.driver.start break # Success, exit the loop rescue VagrantPlugins::Utm::Errors::UtmctlError => e # Only retry if it's an OSStatus error (configuration still being saved) raise unless e..include?("OSStatus") retry_count += 1 # If we've exhausted all retries, re-raise the error raise if retry_count >= max_retries = "VM configuration may still be saving. Retrying in #{retry_delay} seconds... " \ "(#{retry_count}/#{max_retries})" env[:ui].warn sleep retry_delay retry_delay *= 2 # Exponential backoff: 1s, 2s, 4s end @app.call(env) end |