Sha256: 087c5115485c2bffe2ef2844e1b44f3ab75e7dba85547ee3180ae8db73cc08fb

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 KB

Contents

# Encoding: utf-8

# Qless requires
require 'qless'
require 'qless/worker/base'

module Qless
  module Workers
    # A worker that keeps popping off jobs and processing them
    class SerialWorker < BaseWorker
      def initialize(reserver, options = {})
        super(reserver, options)
      end

      def run
        log(:info, "Starting #{reserver.description} in #{Process.pid}")
        procline "Starting #{reserver.description}"
        register_signal_handlers

        reserver.prep_for_work!

        listen_for_lost_lock do
          procline "Running #{reserver.description}"

          jobs.each do |job|
            # Run the job we're working on
            log(:debug, "Starting job #{job.klass_name} (#{job.jid} from #{job.queue_name})")
            perform(job)
            log(:debug, "Finished job #{job.klass_name} (#{job.jid} from #{job.queue_name})")

            # So long as we're paused, we should wait
            while paused
              log(:debug, 'Paused...')
              sleep interval
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
qless-0.12.0 lib/qless/worker/serial.rb
qless-0.11.0 lib/qless/worker/serial.rb
qless-0.10.5 lib/qless/worker/serial.rb
qless-0.10.4 lib/qless/worker/serial.rb
qless-0.10.3 lib/qless/worker/serial.rb
qless-0.10.2 lib/qless/worker/serial.rb
qless-0.10.1 lib/qless/worker/serial.rb
qless-0.10.0 lib/qless/worker/serial.rb