I have backgroundrb working locally and everything''s fine. However, i can''t get it running on our server. I read a blog post by David Burger about backgroundrb (http://david-burger.blogspot.com/2008/04/backgroundrb-rails-notes.html#comment-form) and it says that you set up your backgroundrb.yml file with a different section for each environment you want to use. Mine looks like this: --- :backgroundrb: :ip: 0.0.0.0 :port: 11007 :development: :backgroundrb: :port: 11006 :environment: development :persistent_delay: 2 :staging: :backgroundrb: :port: 11007 :environment: staging :persistent_delay: 10 :production: :backgroundrb: :port: 11008 :environment: production :persistent_delay: 15 The environment i''m trying to get it working in initially is ''staging'' (our server-based environment for playing with new stuff before deploying it to the live server). I set a different persistent_delay in each environment just so i could watch the log file and see what''s going on. I start backgroundrb like this: sudo ./script/backgroundrb start -e staging The server starts ok, and in my staging.log i can see it querying the job queue table every five seconds (the default time). So, it seems to be running, but ignoring my ''staging'' settings. When i try and call it from the console or my app, i get this error: BackgrounDRb::NoServerAvailable Can anyone help? thanks, max -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, Oct 14, 2008 at 7:17 PM, Max Williams <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I have backgroundrb working locally and everything''s fine. However, i > can''t get it running on our server. > > I read a blog post by David Burger about backgroundrb > (http://david-burger.blogspot.com/2008/04/backgroundrb-rails-notes.html#comment-form) > and it says that you set up your backgroundrb.yml file with a different > section for each environment you want to use. Mine looks like this: > > --- > :backgroundrb: > :ip: 0.0.0.0 > :port: 11007 > > :development: > :backgroundrb: > :port: 11006 > :environment: development > :persistent_delay: 2 > > :staging: > :backgroundrb: > :port: 11007 > :environment: staging > :persistent_delay: 10 > > :production: > :backgroundrb: > :port: 11008 > :environment: production > :persistent_delay: 15 > > The environment i''m trying to get it working in initially is ''staging'' > (our server-based environment for playing with new stuff before > deploying it to the live server). I set a different persistent_delay in > each environment just so i could watch the log file and see what''s going > on. I start backgroundrb like this: > > sudo ./script/backgroundrb start -e staging > > The server starts ok, and in my staging.log i can see it querying the > job queue table every five seconds (the default time). So, it seems to > be running, but ignoring my ''staging'' settings. When i try and call it > from the console or my app, i get this error: > > BackgrounDRb::NoServerAvailable >This feature of recursively merging environments was removed from version 1.0.4 and hence your code may not work. Alternately, you can try applying following diff (if you have up to date copy of bdrb from git): diff --git a/lib/backgroundrb/bdrb_config.rb b/lib/backgroundrb/bdrb_config.rb index adde8b9..5c76346 100644 --- a/lib/backgroundrb/bdrb_config.rb +++ b/lib/backgroundrb/bdrb_config.rb @@ -33,6 +33,16 @@ module BackgrounDRb Object.const_set("RAILS_ENV",environment) end + if config[environment] + deep_proc = Proc.new do |key, oldval, newval| + if oldval.kind_of?(Hash) && newval.kind_of?(Hash) + next oldval.merge(newval,&deep_proc) + end + next newval + end + config.merge!( config[environment], &deep_proc) + end + ENV["RAILS_ENV"] = environment config end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Kumar (or should i call you Hemant?) I do have the latest version from git and i tried just manually patching in your chunk of code. But it didn''t seem to make any difference. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Max Williams wrote: Hi Hemant I found the problem - the code you gave me doesn''t work with the config, because having a colon at the start of the variable names, like this :development: :backgroundrb: :port: 11006 :environment: development :persistent_delay: 2 This means that the keys in the config hash that is built up all start with a colon and are interpreted as symbols rather than strings. So, i end up with a hash that looks like this: config = {:development => {:backgroundrb => {:port => 11006, etc}} {:staging => {:backgroundrb => etc etc BUT, the environment variable, set with -e, is a regular string. So, if i start backgroundrb with "-e staging", it tries to match "staging" against :staging, doesn''t find a match, and so goes with the defaults. I fixed this in mine by converting the environment variable to a symbol before comparing with the config hash: here''s my altered version of the code you gave me in the earlier post: if config[environment.to_sym] deep_proc = Proc.new do |key, oldval, newval| if oldval.kind_of?(Hash) && newval.kind_of?(Hash) next oldval.merge(newval,&deep_proc) end next newval end config.merge!( config[environment.to_sym], &deep_proc) end Thanks max -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---