Created
April 19, 2012 17:55
-
-
Save tatiC/2422603 to your computer and use it in GitHub Desktop.
Usando resque-redis numa applicação Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
refs: https://github.com/defunkt/resque | |
Instalar redis | |
Instalar resque | |
Gemfile: gem 'resque', 'versão', :require => 'resque/server' | |
Criar arquivo: | |
lib/tasks/resque.rake | |
require "resque/tasks" | |
task "resque:setup" => :environment | |
-------------------------------------- | |
No arquivo application.rb: | |
config.autoload_paths += %W( | |
#{config.root}/lib/tasks) | |
-------------------------------------- | |
Criar app/workers/nome_arquivo.rb | |
class NomeArquivo | |
@queue = :nome_queue | |
def self.perform(objeto_id) | |
------- | |
end | |
end | |
-------------------------------------- | |
No controller | |
Resque.enqueue(NomeArquivo, objeto.id) | |
Inicia servidor-redis:(port 6379) | |
alias redis="cd ~/Dropbox/work/projects/resque;redis-server" | |
Para visualizar filas:(port: 5678) | |
alias filas="resque-web" | |
Inicia worker: | |
rake resque:work QUEUE=nome_queue | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment