How to separate workers from task pools with deferred work + hero?

My environment is rails 3.1, a stack of bamboo heroics, delayed_job_active_record, (https://github.com/collectiveidea/delayed_job) and is experimenting with hiring. (https://github.com/meskyanichi/hirefire) - I can see the documentation about queue delay, but how to apply this to the hero?

I have a set of priorities with the highest priority, which is generated every hour, which I need to devote 3 workers, it will take about 26 minutes. During this time, less important background tasks should be continued, possibly with one employee dedicated to them.

So, I will put this block of priority tasks in a named queue, for example. 'hourtask' and then name the queue for everything else 'allelse' :)

The question is, how do I dedicate the hero of the workers to specific lines? Is this somehow related to environment variables as per the documentation? It says:

# Set the --queue or --queues option to work from a particular queue.
$ RAILS_ENV=production script/delayed_job --queue=tracking start
$ RAILS_ENV=production script/delayed_job --queues=mailers,tasks start

But I'm not familiar enough with installing heroku to figure out how to apply this to my heroku workspace?

+5
source share
2 answers

In README for Delayed Job 3:

DJ 3 introduces Resque-style name queues while maintaining DJ style priority. The goal is to provide a system for grouping tasks that will be handled by separate pools of workers that can be scaled and controlled individually.

Jobs can be assigned to a queue by setting the queue option:

object.delay(:queue => 'tracking').method

Delayed::Job.enqueue job, :queue => 'tracking'

handle_asynchronously :tweet_later, :queue => 'tweets'

script / delayed_job can be used to control the background process, which will begin to perform tasks.

, gem "" Gemfile , rails generate delayed_job.

:

$ RAILS_ENV=production script/delayed_job start
$ RAILS_ENV=production script/delayed_job stop

# Runs two workers in separate processes.
$ RAILS_ENV=production script/delayed_job -n 2 start
$ RAILS_ENV=production script/delayed_job stop

# Set the --queue or --queues option to work from a particular queue.
$ RAILS_ENV=production script/delayed_job --queue=tracking start
$ RAILS_ENV=production script/delayed_job --queues=mailers,tasks start

, QUEUE QUEUES.

QUEUE=tracking rake jobs:work
QUEUES=mailers,tasks rake jobs:work

Heroku, procfile, :

worker1: QUEUE=tracking rake jobs:work
worker2: QUEUES=mailers,tasks rake jobs:work

:

heroku ps:scale worker1=2 worker2=1 

..

+14

HireFire. HireFire (. HireFire), .

+1

All Articles