Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you run multiple DelayedJob workers on a single Heroku dyno?

I am having trouble getting my dynos to run multiple delayed job worker processes.

My Procfile looks like this:

worker: bundle exec script/delayed_job -n 3 start

and my delayed_job script is the default provided by the gem:

#!/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 this either locally or on a Heroku dyno it exits silently and I can't tell what is going on.

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 with either how to debug the issue or suggestions about other ways to go about running multiple workers on a single dyno it would be greatly appreciated.

like image 328
Andrew Hubbs Avatar asked Jul 16 '14 23:07

Andrew Hubbs


1 Answers

Try changing your Procfile to:

worker: bundle exec script/delayed_job -n 3 run

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

Using run keeps the workers in the foreground.

UPDATE: I use Delayed Job Worker Pool for this now.

like image 110
davogones Avatar answered Oct 19 '22 07:10

davogones