Class: ProcessBot::Process::RunnerInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/process_bot/process/runner_instance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runner:, event_queue:, logger:) ⇒ RunnerInstance

Returns a new instance of RunnerInstance.



4
5
6
7
8
# File 'lib/process_bot/process/runner_instance.rb', line 4

def initialize(runner:, event_queue:, logger:)
  @runner = runner
  @event_queue = event_queue
  @logger = logger
end

Instance Attribute Details

#runnerObject (readonly)

Returns the value of attribute runner.



2
3
4
# File 'lib/process_bot/process/runner_instance.rb', line 2

def runner
  @runner
end

#threadObject (readonly)

Returns the value of attribute thread.



2
3
4
# File 'lib/process_bot/process/runner_instance.rb', line 2

def thread
  @thread
end

Instance Method Details

#running?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/process_bot/process/runner_instance.rb', line 21

def running?
  runner.running?
end

#startObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/process_bot/process/runner_instance.rb', line 10

def start
  @thread = Thread.new do
    runner.run
    event_queue << {type: :stopped, runner_instance: self}
  rescue => e # rubocop:disable Style/RescueStandardError
    logger.error e.message
    logger.error e.backtrace
    event_queue << {type: :error, runner_instance: self, error: e}
  end
end