> 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 ... > > -- SteveSteve, 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
Nathan Murray
2007-May-07 20:13 UTC
[Backgroundrb-devel] Daemons closes files? (Breaks logging while testing)
Hey guys, I''m working really hard to get the unit tests for Workers to work with Rails. I''m hoping I can figure it out and submit a patch. I''ve made really great progress in so far as I can run basic unit tests. I am starting up the BRB server just for the test and then bringing it back down. I think this makes the most sense for an accurate test and it isn''t very slow. The biggest issue I am having is that ActiveRecord::Base.logger''s file descriptor keeps getting closed and throwing tons of errors anytime I try to do anything. (As a side note, the DB connection seems to be rolling back before my workers have a chance to get at it, but I think that''s a different issue.) I think this is because Daemons is closing the file, but I''m not exactly sure. From the Daemons documentation: ... 6. Closes file descriptors (reopens STDOUT and STDERR to point to a logfile if possible). ... I''m guessing that Daemons is rightly trying to be its own independent process but while doing that it seems to close the Rails logger. Does anyone have any suggestions on how to reconcile these issues? Testing is very important to us here as this is a production-level business app. I really love the idea behind BackgrounDRb and I want to contribute my changes to the community so any help would be greatly appreciated! Nate Murray http://pasadenarb.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20070507/ffc000cb/attachment-0001.html