Background jobs
JSON pending jobs in Redis
Ruby
multiples Queues
Persistents Workers
Classes that respond to `perform`
Slide 5
Slide 5 text
# lib/resque/archive.rb
class Archive
@queue = :file_serve
def self.perform(repo_id, branch = 'master')
repo = Repository.find(repo_id)
repo.create_archive(branch)
end
end
# app/models/repository.rb
class Repository
def async_create_archive(branch)
Resque.enqueue(Archive, self.id, branch)
end
end
Slide 6
Slide 6 text
RESQUE-WEB
Slide 7
Slide 7 text
Steve Klabnik
"Yet Another GitHub
Project They've Open
Sourced and Then
Abandoned."
But Resque is super
awesome [...]
http://blog.steveklabnik.com/posts/2012-09-22-resque--let-s-do-this
daily_digest:
cron: "0 */24 * * *"
class: Digest
description: "The one time a day activity digest"
args: [1]
bidaily_digest:
cron: "0 */12 * * *"
class: Digest
description: "The two time a day activity digest"
args: [2]
instant_digest:
cron: "*/5 * * * *"
class: Digest
description: "Send each 5 minuts a digest"
args: [3]
Run | production
★ Configure Upstart to auto-restart workers
when they are down.
★ Capistrano deploy hook to shutdown
running workers.
after "deploy:create_symlink", "deploy:stop_resque"