Background jobs with Resque on Heroku

I managed to solve the problem by playing with my config a little. It seems that actions were being tunnelled through ActiveJob's "Inline" default rather than via Resque. To get things working I just had to direct Resque.redis to be equal to the $redis variable set in config/initializers/redis.rb so everything was pointing to the same Redis instance and then move the config set in config/initializers/active_job.rb to application.rb.

For reference, the new & improved config that all works is:

Config / setup

Procfile

web: bundle exec puma -C config/puma.rb
resque: env TERM_CHILD=1 RESQUE_TERM_TIMEOUT=7 QUEUE=* bundle exec rake resque:work

lib/tasks/resque.rake

require "resque/tasks"

task "resque:setup" => :environment

config/application.rb

module App
  class Application < Rails::Application
    ...

    # Set Resque as ActiveJob queue adapter.
    config.active_job.queue_adapter = :resque
  end
end

config/initializers/redis.rb

if ENV["REDISCLOUD_URL"]
  $redis = Redis.new(url: ENV["REDISCLOUD_URL"])
end

config/initializers/resque.rb

Resque.redis = Rails.env.production? ? $redis : "localhost:6379"

thanks a lot for providing the answer. It saved me a lot of time.

You have one typo inside your Procfile.

It should be resque instead of rescue.

resque: env TERM_CHILD=1 RESQUE_TERM_TIMEOUT=7 QUEUE=* bundle exec rake resque:work

Also, I had to type in one more command to get this all to work in production. Hopefully this helps someone.

heroku ps:scale resque=1 --app appname

This command scales the resque process to 1 dyno(free). You can also do this from the dashboard on heroku.

You can read more about it on the heroku docs https://devcenter.heroku.com/articles/scaling