Class: VagrantPlugins::OrbStack::Action::Halt
- Inherits:
-
Object
- Object
- VagrantPlugins::OrbStack::Action::Halt
- Includes:
- MachineValidation
- Defined in:
- lib/vagrant-orbstack/action/halt.rb
Overview
Action middleware for halting (stopping) OrbStack machines
This middleware handles stopping a running OrbStack machine gracefully. It calls the OrbStack CLI to stop the machine and invalidates the provider's state cache to ensure subsequent state queries are fresh.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Execute the middleware.
-
#initialize(app, _env) ⇒ Halt
constructor
Initialize the middleware.
Methods included from MachineValidation
Constructor Details
#initialize(app, _env) ⇒ Halt
Initialize the middleware.
29 30 31 |
# File 'lib/vagrant-orbstack/action/halt.rb', line 29 def initialize(app, _env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
Execute the middleware.
Halts the machine by calling OrbStack CLI stop command, then invalidates the state cache to ensure fresh state queries.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vagrant-orbstack/action/halt.rb', line 43 def call(env) machine = env[:machine] ui = env[:ui] # Validate machine ID exists machine_id = validate_machine_id!(machine, 'halt') ui.info("Halting machine '#{machine_id}'...") # Call OrbStack CLI to stop the machine Util::OrbStackCLI.stop_machine(machine_id) # Invalidate state cache to ensure fresh state on next query machine.provider.invalidate_state_cache # Continue middleware chain @app.call(env) end |