class Aruba::Command

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.

@see BasicProcess @see SpawnProcess

@private

Attributes

event_bus[R]

Public Class Methods

new(command, opts = {}) click to toggle source
Calls superclass method
# File lib/aruba/command.rb, line 25
def initialize(command, opts = {})
  launchers = []
  launchers << Processes::DebugProcess
  launchers << Processes::InProcess
  launchers << Processes::SpawnProcess

  launcher = launchers.find { |l| l.match? opts[:mode] }

  super launcher.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)
  )

  @event_bus = opts.fetch(:event_bus)
rescue KeyError => e
  raise ArgumentError, e.message
end

Public Instance Methods

run!()
Alias for: start
start() click to toggle source

Start command

# File lib/aruba/command.rb, line 68
def start
  __getobj__.start
  event_bus.notify Events::CommandStarted.new(self)

  self
end
Also aliased as: run!
stop(*) click to toggle source

Stop command

# File lib/aruba/command.rb, line 50
def stop(*)
  __getobj__.stop
  event_bus.notify Events::CommandStopped.new(self)

  self
end
terminate(*) click to toggle source

Terminate command

# File lib/aruba/command.rb, line 58
def terminate(*)
  return if __getobj__.stopped?

  __getobj__.terminate
  event_bus.notify Events::CommandStopped.new(self)

  self
end