PIDFILE=./resque.pid QUEUE=file_serve rake environment resque:work
gem 'resque', :require => "resque/server"
require "resque/tasks" task "resque:setup" => :environment
# -*- encoding: utf-8 -*- # 文件转换后台运行程序,用于将mp4的文件转换成可以在手机上观看的rtsp, rtmp的视频文件 class FileConvertWorker @queue = :file_convert_que #视频的id号 def self.perform(video_id) video = Video.find_by_id video_id if video #.... .... end end end
Resque.enqueue(FileConvertWorker, video.id)
mount Resque::Server, :at => "/resque"
Resque::Server.use(Rack::Auth::Basic) do |user, password| password == "secret" end
rake resque:work QUEUE='*'启动多个resque线程
COUNT=5 QUEUE=* rake resque:workers
Resque.enqueue(FileConvertWorker, video.id)
VVERBOSE=1 QUEUE=file_serve rake environment resque:work
PIDFILE=./resque.pid QUEUE=file_serve rake environment resque:work
PIDFILE=./resque.pid BACKGROUND=yes QUEUE=file_serve \
rake environment resque:work
INTERVAL=0.1 QUEUE=file_serve rake environment resque:work
resque不支持数字化的优先级
resque的解决方案是 提供不同优先级的 queue name, 如下命令
QUEUES=critical,archive,high,low rake resque:work
如果只有 archive 后台命令,那么 他会按照一定的次序. 如果发现 critical 那么会先执行 critical