On 7 Sep 2008, at 16:41, Bill Walton wrote:
> > Hi Michael, > > Michael Allman wrote: >> >> I'm developing a rails 2 app with a custom database for persistence >> (not activerecord, not sql). I need to open the database once at >> application startup and close it once at application shutdown. I >> figured out how to add an application startup hook by putting a >> script >> in config/initializers. I can't figure out how to add a shutdown >> hook. Can someone point me in the right direction? I really need to >> close the database properly at shutdown time. > > You may be misunderstanding one of the basics of Rails > applications. Rails > apps are not daemons that start up and then sit there running, > waiting for a > next request. A Rails app exists for exactly one request - response > cycle. > It starts up when it receives a request, and it shuts down after it > delivers > its response. Um what? Something like a mongrel instance is exactly something that sits there and waits for requests to come in. Fred > When it receives another request the cycle is repeated. > Easiest thing in your case could be to define a start up method and > a shut > down method. Your start up method could be called based on a global > or a > class singleton. Your shut down method will probably have to be > invoked > explicitly though. > > HTH, > Bill > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

