Module: Barbeque::Worker
- Defined in:
- lib/barbeque/worker.rb
Defined Under Namespace
Classes: UnexpectedMessageType
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.run(worker_type: 'process', workers: 4, daemonize: false, log: $stdout, log_level: :info, pid_path: '/tmp/barbeque_worker.pid', supervisor: true) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/barbeque/worker.rb', line 11 def self.run( worker_type: 'process', workers: 4, daemonize: false, log: $stdout, log_level: :info, pid_path: '/tmp/barbeque_worker.pid', supervisor: true ) = { worker_type: worker_type, workers: workers, daemonize: daemonize, log: log, log_level: log_level, pid_path: pid_path, supervisor: supervisor, } worker = ServerEngine.create(nil, Barbeque::Worker, ) worker.run end |
Instance Method Details
#execute_command ⇒ Object
63 64 65 |
# File 'lib/barbeque/worker.rb', line 63 def execute_command @command.run end |
#initialize ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/barbeque/worker.rb', line 34 def initialize @command = case worker_id when 0 ExecutionPoller.new when 1 RetryPoller.new else Runner.new end end |
#run ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/barbeque/worker.rb', line 46 def run $0 = "barbeque-worker (worker_id=#{worker_id} command=#{@command.class.name})" until @stop begin execute_command rescue => e Barbeque::ExceptionHandler.handle_exception(e) end Barbeque::ExceptionHandler.clear_context end end |
#stop ⇒ Object
58 59 60 61 |
# File 'lib/barbeque/worker.rb', line 58 def stop @stop = true @command.stop end |