[Backgroundrb-devel] Setting environment

Nathan Murray nate at natemurray.com
Fri May 4 15:41:32 EDT 2007


> Chris T wrote:
> > Not sure this is known behaviour but it seems that if want to set  
> the
> > environment to, for example, test, and you want to use Active  
> Record you
> > have to both explicitly set the RAILS_ENV and the BackgrounDRb  
> environment.
>
> I ran into essentially the same problem (needing to run BRB in the  
> test
> environment so AR would use the right DB).  My "solution" was to  
> add entries
> in backgroundrb.yml for environment, log_file and pid_file to allow  
> for
> multiple instances of BRB to run simultaneously in different  
> environments.  My
> config now looks like:
>
> environment: <%= ENV['RAILS_ENV'] %>
> port: <%= 22222 + ['production', 'development', 'test'].index(ENV 
> ['RAILS_ENV']) %>
> log_file: <%= "log/brb-#{ENV['RAILS_ENV']}.log" %>
> pid_file: <%= "log/brb-#{ENV['RAILS_ENV']}.pid" %>
> ...
>
> Obviously, I had to hack BRB to use these settings, modify the  
> start/stop
> scripts to take an --env argument, and add Rake tasks to (re)start  
> the test
> instance.  Add that restart task as a preqreq of 'test', and the  
> BRB test
> instance will restart (and reload) before each test run.
>
> If interested, I can provide diffs ...
>
> -- Steve

Steve, I'm interested in the diffs. I'd like to the same thing.

Nate Murray
http://pasadenarb.com




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20070504/c8ee1d9f/attachment.html 


More information about the Backgroundrb-devel mailing list