How do you run multiple DelayedJob employees on the same Heroku dinar?

I'm having trouble getting my speakers to run multiple pending workflows.

My Procfile looks like this:

worker: bundle exec script/delayed_job -n 3 start 

and my delayed_job script is provided by default by stone:

 #!/usr/bin/env ruby require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment')) require 'delayed/command' Delayed::Command.new(ARGV).daemonize 

When I try to run it either locally or on the Heroku speaker, it exits silently, and I cannot say what is happening.

 foreman start 16:09:09 worker.1 | started with pid 75417 16:09:15 worker.1 | exited with code 0 16:09:15 system | sending SIGTERM to all processes SIGTERM received 

Any help on how to debug a problem or suggestions on other ways to run multiple employees on the same dinogen would be very helpful.

+7
ruby-on-rails heroku delayed-job foreman procfile
source share
3 answers

You can use the wizards to run multiple processes on the same dynamics.

First add the wizards to your Gemfile.

Then add the worker line to your Procfile :

 worker: bundle exec foreman start -f Procfile.workers 

Create a new file called Procfile.workers that contains:

 dj_worker: bundle exec rake jobs:work dj_worker: bundle exec rake jobs:work dj_worker: bundle exec rake jobs:work 

This will start 3 workers with a delay_job on your working dino.

+12
source share

Try changing your Procfile to:

worker: bundle exec script/delayed_job -n 3 run

Using start will create two daemons in the background and exit immediately. Heroku believes your process crashed.

Using run keeps workers in the foreground.

UPDATE: for this I am currently using the Delayed jobs pool .

+5
source share

Short answer: you cannot do this with delayed_job. Dino is a process, and one delayed_job worker is working on one process.

There are other solutions for this. If you can switch to using Sidekiq, then you can run quite a few workers in one process, as Sidekiq workers use threads. The trade-off here is that your employees should be thread safe.

Check it out: http://sidekiq.org/

0
source share

All Articles