Class: Pubilion::Worker::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/pubilion/worker/runner.rb

Overview

Runner for Pubilion worker

Constant Summary collapse

WAIT_INTERVAL =
1
EXIT_SIGNALS =
%w[SIGTERM SIGINT].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Runner

Returns a new instance of Runner.



12
13
14
15
# File 'lib/pubilion/worker/runner.rb', line 12

def initialize(config)
  @handler = Pubilion::Worker::MessageHandler.new
  @subscriber = Pubilion::Worker::Subscriber.new(config, @handler)
end

Instance Attribute Details

#subscriberObject (readonly)

Returns the value of attribute subscriber.



10
11
12
# File 'lib/pubilion/worker/runner.rb', line 10

def subscriber
  @subscriber
end

Instance Method Details

#runObject

Start worker and wait for exits.



18
19
20
21
22
23
24
# File 'lib/pubilion/worker/runner.rb', line 18

def run
  subscriber.run

  wait_for_exits
ensure
  subscriber.shutdown
end