Live data from Hacker News

Resque with Redis To Go

blog.redistogo.com

11–20 of 20 posts

Re: Resque with Redis To Go

#11
post #6

Looks pretty awesome. I'd love to use it on an upcoming project. 2 questions: 1. Do jobs (in app/jobs/whatever.rb) have full access to your Rails models (so you can pass it an ID and it can do whatever)? 2. How does the rake task/worker best work in a production environment (other than Heroku)? Use monit to keep the worker(s) up? Thanks

1. It's optional.

"rake environment resque:work" will give you access to the whole rails environment, so you can write normal rails code. But it of course uses a bunch of memory.

If you're doing something quick and dirty and don't need the rails model (sending out a password email or whatever), you can just run "rake resque:work" and avoid the overhead of the whole rails environment.

Re: Resque with Redis To Go

#12
post #11
post #6

Looks pretty awesome. I'd love to use it on an upcoming project. 2 questions: 1. Do jobs (in app/jobs/whatever.rb) have full access to your Rails models (so you can pass it an ID and it can do whatever)? 2. How does the rake task/worker best work in a production environment (other than Heroku)? Use monit to keep the worker(s) up? Thanks

1. It's optional. "rake environment resque:work" will give you access to the whole rails environment, so you can write normal rails code. But it of course uses a bunch of memory. If you're doing something quick and dirty and don't need the rails model (sending out a password email or whatever), you can just run "rake resque:work" and avoid the overhead of the whole rails environment.

The line `task "resque:setup" => :environment` in the rake file does the same thing. That way it will load the env on Heroku.

Re: Resque with Redis To Go

#13
post #11

Earlier quoted context omitted.

1. It's optional. "rake environment resque:work" will give you access to the whole rails environment, so you can write normal rails code. But it of course uses a bunch of memory. If you're doing something quick and dirty and don't need the rails model (sending out a password email or whatever), you can just run "rake resque:work" and avoid the overhead of the whole rails environment.

The line `task "resque:setup" => :environment` in the rake file does the same thing. That way it will load the env on Heroku.

Yes, of course, I guess I was just trying to say that rails is optional, not required, and that resque is a pretty nice general purpose job queue.

Re: Resque with Redis To Go

#15
post #7

Great stuff! Also, for the extremely anal, uri-redis is aware of the database number: require 'uri-redis' conf = URI.parse 'redis://localhost:6379/1' conf.host # => localhost conf.port # => 6379 conf.db # => 1

Redis also manages URLs directly: Redis.connect('redis://localhost:6379/1') works as expected.

Re: Resque with Redis To Go

#16
post #15
post #7

Great stuff! Also, for the extremely anal, uri-redis is aware of the database number: require 'uri-redis' conf = URI.parse 'redis://localhost:6379/1' conf.host # => localhost conf.port # => 6379 conf.db # => 1

Redis also manages URLs directly: Redis.connect('redis://localhost:6379/1') works as expected.

I had no idea! And I've been parsing them myself all this time.

Re: Resque with Redis To Go

#17
post #15
post #7

Great stuff! Also, for the extremely anal, uri-redis is aware of the database number: require 'uri-redis' conf = URI.parse 'redis://localhost:6379/1' conf.host # => localhost conf.port # => 6379 conf.db # => 1

Redis also manages URLs directly: Redis.connect('redis://localhost:6379/1') works as expected.

Does that work with passwords?

Re: Resque with Redis To Go

#19
post #15
post #7

Great stuff! Also, for the extremely anal, uri-redis is aware of the database number: require 'uri-redis' conf = URI.parse 'redis://localhost:6379/1' conf.host # => localhost conf.port # => 6379 conf.db # => 1

Redis also manages URLs directly: Redis.connect('redis://localhost:6379/1') works as expected.

That should be Redis.connect(:url => 'redis://localhost:6379/1')

Re: Resque with Redis To Go

#20
You can make the resque-web app available under /resque simply by:

require 'resque'

MyApp::Application.routes.draw do

  mount Resque::Server.new, :at => "/resque"
end

Requires Rails 3.

Post reply on HN