Resque Scheduler发送到队列但不处理

时间:2014-05-10 00:07:00

标签: heroku resque resque-scheduler

我在我的开发环境中启动并运行resque和resque调度程序,但是当我部署到heroku时,似乎调度程序没有完成其工作。它保持延迟状态,永远不会被移动到队列中。

这是我的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

这是我的resque.rake文件

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"

我的视频控制器创建操作正在执行此操作

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

我正在使用Procfile,因为heroku推荐resque使用它。

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

1 个答案:

答案 0 :(得分:4)

哇哇哇哇哇哇哇哇哇哇哇哇哇!

将我的resque.rake文件更改为此

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"

我也将此添加到我的个人资料

scheduler: bundle exec rake resque:scheduler

我做的最后一件事是在我的调度程序上放大了一个dyno

heroku ps:scale scheduler=1