librelist archives

« back to archive

What changes must you make to your resque setup in order to run workers in a custom environment you've created (not development or production)?

What changes must you make to your resque setup in order to run workers in a custom environment you've created (not development or production)?

From:
David Parkinson
Date:
2011-05-20 @ 20:01
I have got resque working when I do: "QUEUE=blah rake resque:work".  But the
moment I add in "RAILS_ENV=backend QUEUE=blah rake resque:work".  I get,
"undefined method `get' for nil:NilClass".  'backend' is custom environment
that I've created.  And I think I've addressed the environment as a valid
redis/resque enviornment, but obviously not!  :)

I.e. what do I need to do to make resque work for a different
rails environment?

/config/redis.yml
backend: localhost:6379
development: localhost:6379
test: localhost:6379
production: localhost:6379

/config/initializers/redis.rb:
rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
rails_env = ENV['RAILS_ENV'] || 'development'

resque_config = YAML.load_file(rails_root + '/config/resque.yml')
Resque.redis = resque_config[rails_env]



=David

--
http://www.davidparkinson.com
http://www.linkedin.com/in/davidcparkinson

Re: [resque] What changes must you make to your resque setup in order to run workers in a custom environment you've created (not development or production)?

From:
Stephen Paul Suarez
Date:
2011-05-20 @ 20:17
i'm not really an expert on the internals of resque, but knowing that  
it is agnostic to rails environments(it even runs on sinatra).. it  
might be helpful to try to manually configure it in script/console.. i  
hope your resque.yml isn't missing the backend key..

On May 21, 2011, at 4:01 AM, David Parkinson wrote:

> I have got resque working when I do: "QUEUE=blah rake resque:work".   
> But the moment I add in "RAILS_ENV=backend QUEUE=blah rake  
> resque:work".  I get, "undefined method `get' for nil:NilClass".   
> 'backend' is custom environment that I've created.  And I think I've  
> addressed the environment as a valid redis/resque enviornment, but  
> obviously not!  :)
>
> I.e. what do I need to do to make resque work for a different rails  
> environment?
>
> /config/redis.yml
> backend: localhost:6379
> development: localhost:6379
> test: localhost:6379
> production: localhost:6379
>
> /config/initializers/redis.rb:
> rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
> rails_env = ENV['RAILS_ENV'] || 'development'
>
> resque_config = YAML.load_file(rails_root + '/config/resque.yml')
> Resque.redis = resque_config[rails_env]
>
>
>
> =David
>
> --
> http://www.davidparkinson.com
> http://www.linkedin.com/in/davidcparkinson

Re: What changes must you make to your resque setup in order to run workers in a custom environment you've created (not development or production)?

From:
David Parkinson
Date:
2011-05-20 @ 20:11
Nevermind!  I realized that (although I REALLY THOUGHT) I had defined the
backend environment in config/resque.yml; I had not.  How can I expect
resque to work if I don't give it the redis instance to connect to?

I realized this when I was starting to create an issue on GitHub and then
was flabbergasted that there was no backend enviornment in the resque.yml.
 Just goes to show you that composing a thoughtful question can help you
find the answer!

=David

--
http://www.davidparkinson.com
http://www.linkedin.com/in/davidcparkinson


On Fri, May 20, 2011 at 1:01 PM, David Parkinson
<david@davidparkinson.com>wrote:

> I have got resque working when I do: "QUEUE=blah rake resque:work".  But
> the moment I add in "RAILS_ENV=backend QUEUE=blah rake resque:work".  I get,
> "undefined method `get' for nil:NilClass".  'backend' is custom environment
> that I've created.  And I think I've addressed the environment as a valid
> redis/resque enviornment, but obviously not!  :)
>
> I.e. what do I need to do to make resque work for a different
> rails environment?
>
> /config/redis.yml
> backend: localhost:6379
> development: localhost:6379
> test: localhost:6379
> production: localhost:6379
>
> /config/initializers/redis.rb:
> rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
> rails_env = ENV['RAILS_ENV'] || 'development'
>
> resque_config = YAML.load_file(rails_root + '/config/resque.yml')
> Resque.redis = resque_config[rails_env]
>
>
>
> =David
>
> --
> http://www.davidparkinson.com
> http://www.linkedin.com/in/davidcparkinson
>