From: Ezra Zygmuntowicz Date: 2007-08-02T05:10:51+09:00 Subject: Re: Railless ActiveRecord On Aug 1, 2007, at 12:51 PM, Luke Kanies wrote: > On Jul 31, 2007, at 9:37 PM, Ari Brown wrote: > >> Hey all. More ActiveRecord trouble. >> >> So I have my ActiveRecord connection. All is good. I am connecting >> to an SQLite3 database, which is working out pretty well for me. I >> think. > > FWIW, I'm also using ActiveRecord outside of Rails, it might help > to look through my examples, including how I handle my migrations: > > https://reductivelabs.com/trac/puppet/browser/trunk/lib/puppet/ > rails.rb > https://reductivelabs.com/trac/puppet/browser/trunk/lib/puppet/rails > > Note that my usage of ActiveRecord seems to spawn a new connection > on every request, which I can't seem to fix. Luke- Do you have ActiveRecord::Base.allow_concurrency = true ? If so AR uses one database connection per thread so I assume you have a multithreaded server. The way to get rid of old connections is to call ActiveRecord::Base.verify_active_connections! every 10-20 requests. It will cleanup all the old connections whos threads have finished. Cheers- -- Ezra Zygmuntowicz -- Founder & Ruby Hacker -- ez@engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)