Joined June 2012
·

David Somers

Technical Lead at PXi Ventures
·
Milton Keynes, UK
·
·
·

Rails is black magic. That's insane.

Posted to Free background jobs on heroku over 1 year ago

I actually implemented it. Time will tell if it works for sure. This kills the parent process as well, which on Heroku will bounce your entire dyno (which is what I wanted):

@worker_pid = spawn('bundle exec sidekiq')
t = Thread.new {
  Process.wait(@worker_pid)
  puts "Worker died. Bouncing unicorn."
  Process.kill 'QUIT', Process.pid
}
# Just in case
t.abort_on_exception = true

The idea of using Thread.new { Process.wait() } comes from the implementation of Process.detach, which is essentially the same.

Posted to Free background jobs on heroku over 1 year ago

How would you handle if the process dies? Heroku won't notice & bounce your dyno and Unicorn doesn't notice either.

As I said, you add it to config/application.rb. Is that what you mean?

Achievements
263 Karma
13,260 Total ProTip Views