2

I got resque and resque scheduler up and running on my development environment, but when I deploy to heroku it seems like the scheduler is not doing its job. It stays in delayed and never gets moved to the queue.

Here is my intializer resque.rb

if ENV["REDISTOGO_URL"]
    uri = URI.parse(ENV["REDISTOGO_URL"])
    Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password, :thread_safe => true)
end

require 'resque_scheduler'
require 'resque_scheduler/server'

Resque::Server.use(Rack::Auth::Basic) do |user, password|
  password == "Mysecret"
end

Here is my resque.rake file

require "resque/tasks"
require 'resque_scheduler/tasks'

task "resque:setup" => :environment do 
    ENV['QUEUE'] = '*'
    require 'resque_scheduler'
end

desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => "resque:work"

my video controller create action is doing this

def create
    @video = current_user.videos.build(video_params)
    if @video.save
      if @video.emailfans == true
        Resque.enqueue_at(10.seconds.from_now, NewvideoNotify, @video.id)
      end
      redirect_to @video, notice: 'Video was successfully Posted!'
    else
      render action: 'new'
    end
  end

I am using a Procfile because it was recommended by heroku for resque.

resque: env TERM_CHILD=1 RESQUE_TERM_TIMEOUT=7 bundle exec rake resque:work
Josh
  • 589
  • 5
  • 18

1 Answers1

4

wow stumbled across a fix for this.

altered my resque.rake file to this

require "resque/tasks"
require 'resque_scheduler/tasks'

task "resque:setup" => :environment do 
    ENV['QUEUE'] = '*'
end

task "resque:scheduler_setup" => :environment

desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => "resque:work"

I also added this to my profile

scheduler: bundle exec rake resque:scheduler

last thing i did was scaled up a dyno on my scheduler

heroku ps:scale scheduler=1
Josh
  • 589
  • 5
  • 18
  • Thanks for the really little wonderful help. I have another question. Does your hook before_perform/before_enqueue works ? – Faz Nov 09 '15 at 17:29
  • how did you setup your procfile http://stackoverflow.com/questions/41537142/heroku-procfile-resque-puma-rails-5-resque-scheduler-setup – Chris Hough Jan 08 '17 at 20:20