Sha256: 5f2483b8988b083e1c4eeadccaf0fcf4811efa5f3944cb0bb4aa5b1b37813dcf

Contents?: true

Size: 1.01 KB

Versions: 14

Compression:

Stored size: 1.01 KB

Contents

namespace :qc_plus do
  desc "Start a new worker for the (default or $QUEUE) queue"
  task :work  => :environment do
    puts "Starting up worker for queue #{ENV['QUEUE']}"

    # ActiveRecord::RecordNotFound is ignored by Sentry by default,
    # which shouldn't happen in background jobs.
    if defined?(Sentry)
      Sentry.init do |config|
        config.excluded_exceptions = []
        config.background_worker_threads = 0 if Gem::Version.new(Sentry::VERSION) >= Gem::Version.new('4.1.0')
      end
    elsif defined?(Raven)
      Raven.configure do |config|
        config.excluded_exceptions = []
      end
    end

    @worker = QueueClassicPlus::CustomWorker.new

    trap('INT') do
      $stderr.puts("Received INT. Shutting down.")
      if !@worker.running
        $stderr.puts("Worker has already stopped running.")
      end
      @worker.stop
    end

    trap('TERM') do
      $stderr.puts("Received Term. Shutting down.")
      @worker.stop
    end

    @worker.start
    $stderr.puts 'Shut down successfully'
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
queue_classic_plus-4.0.0.alpha21 lib/queue_classic_plus/tasks/work.rake
queue_classic_plus-4.0.0.alpha20 lib/queue_classic_plus/tasks/work.rake
queue_classic_plus-4.0.0.alpha19 lib/queue_classic_plus/tasks/work.rake
queue_classic_plus-4.0.0.alpha18 lib/queue_classic_plus/tasks/work.rake
queue_classic_plus-4.0.0.alpha17 lib/queue_classic_plus/tasks/work.rake
queue_classic_plus-4.0.0.alpha16 lib/queue_classic_plus/tasks/work.rake
queue_classic_plus-4.0.0.alpha15 lib/queue_classic_plus/tasks/work.rake
queue_classic_plus-4.0.0.alpha14 lib/queue_classic_plus/tasks/work.rake
queue_classic_plus-4.0.0.alpha13 lib/queue_classic_plus/tasks/work.rake
queue_classic_plus-4.0.0.alpha12 lib/queue_classic_plus/tasks/work.rake
queue_classic_plus-4.0.0.alpha11 lib/queue_classic_plus/tasks/work.rake
queue_classic_plus-4.0.0.alpha10 lib/queue_classic_plus/tasks/work.rake
queue_classic_plus-4.0.0.alpha9 lib/queue_classic_plus/tasks/work.rake
queue_classic_plus-4.0.0.alpha8 lib/queue_classic_plus/tasks/work.rake