Skip to content
Nathan Esquenazi edited this page Aug 27, 2017 · 5 revisions

First, you probably want to install beanstalkd, which powers the job queues. Depending on your platform, this should be as simple as (for Ubuntu):

$ sudo apt-get install beanstalkd

Add this line to your application's Gemfile:

gem 'backburner'

And then execute:

$ bundle

Or install it yourself as:

$ gem install backburner

Configuration

Backburner is extremely simple to setup. Just configure basic settings for backburner:

Backburner.configure do |config|
  config.beanstalk_url    = ["beanstalk://127.0.0.1", "..."]
  config.tube_namespace   = "some.app.production"
  config.on_error         = lambda { |e| puts e }
  config.max_job_retries  = 3 # default 0 retries
  config.retry_delay      = 2 # default 5 seconds
  config.default_priority = 65536
  config.respond_timeout  = 120
  config.default_worker   = Backburner::Workers::Simple
  config.logger           = Logger.new(STDOUT)
end

The key options available are:

Option Description
beanstalk_url Address such as 'beanstalk://127.0.0.1' or an array of addresses.
tube_namespace Prefix used for all tubes related to this backburner queue.
on_error Lambda invoked with the error whenever any job in the system fails.
default_worker Worker class that will be used if no other worker is specified.
max_job_retries Integer defines how many times to retry a job before burying.
retry_delay Integer defines the base time to wait (in secs) between job retries.
logger Logger recorded to when backburner wants to report info or errors.

Worker configs

a simple example of the three possible worker configs, choose 1 of the 3 options:

Backburner.configure do |config|
  #
  # ... <your configs here>
  #

  # configs for one worker
  config.default_worker   = Backburner::Workers::Simple
  # configs for one forking worker
  config.default_worker   = Backburner::Workers::Forking
  # configs for ThreadsOnFork
  # "backburner-jobs:threads:garbage_collect:retries"
  config.default_queues   = ["backburner-jobs:20:1000:5"]
  config.default_worker   = Backburner::Workers::ThreadsOnFork
end

New-Relic Agent

If you want to setup instrumentation for Backburner on New Relic, follow NewRelic's instructions on adding the gem and configuring the agent with the YAML file. Then, in an initializer, add the following:

if defined?(::NewRelic)
  Backburner::Job.include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
  Backburner::Job.add_transaction_tracer :process, category: :task
end

This will attach the transaction tracer to the Backburner task processor.

Clone this wiki locally