Class: Aruba::Command
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Aruba::Command
- Defined in:
- lib/aruba/command.rb
Overview
Command
This class is not meant for direct use - Command.new, though it’s API is public. As it is just a wrapper class, have a look at ‘BasicProcess` and the like for the public API.
Instance Method Summary collapse
-
#initialize(command, opts = {}) ⇒ Command
constructor
A new instance of Command.
-
#start ⇒ Object
(also: #run!)
Start command.
-
#stop ⇒ Object
Stop command.
-
#terminate ⇒ Object
Terminate command.
Constructor Details
#initialize(command, opts = {}) ⇒ Command
Returns a new instance of Command.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/aruba/command.rb', line 27 def initialize(command, opts = {}) launchers = [] launchers << Processes::DebugProcess launchers << Processes::InProcess launchers << Processes::SpawnProcess klass = launchers.find { |l| l.match? opts[:mode] } launcher = klass.new( command, opts.fetch(:exit_timeout), opts.fetch(:io_wait_timeout), opts.fetch(:working_directory), opts.fetch(:environment), opts.fetch(:main_class), opts.fetch(:stop_signal), opts.fetch(:startup_wait_time) ) super(launcher) @event_bus = opts.fetch(:event_bus) rescue KeyError => e raise ArgumentError, e. end |
Instance Method Details
#start ⇒ Object Also known as: run!
Start command
74 75 76 77 78 79 |
# File 'lib/aruba/command.rb', line 74 def start __getobj__.start event_bus.notify Events::CommandStarted.new(self) self end |
#stop ⇒ Object
Stop command
54 55 56 57 58 59 60 61 |
# File 'lib/aruba/command.rb', line 54 def stop(*) return if __getobj__.stopped? __getobj__.stop event_bus.notify Events::CommandStopped.new(self) self end |
#terminate ⇒ Object
Terminate command
64 65 66 67 68 69 70 71 |
# File 'lib/aruba/command.rb', line 64 def terminate(*) return if __getobj__.stopped? __getobj__.terminate event_bus.notify Events::CommandStopped.new(self) self end |