Just a quick question about the...
Thread.new{loop{sleep 60; DB.get(1)}}
does this go in the initialize method? of sample code i pasted in the
initial message or does it go else where.I generally have 2 connections per frontend (one for the GUI frontend displaying customer data and another that is created with another class that handles data processing. On 9 December 2010 08:20, dave lilley <[email protected]> wrote: > many thanks for the reply. > > when i get home i'll give the code a try & hopefully this will help someone > else who may hit a similar issue of needing a heartbeat. > > Reason for this limit is that now the DB is going to have a web based front > end for external users to view their data (his problem not mine - I'm > dealing with apps that will be used by him and others). > > I think he's put the time limit to stop lost/dropped connections from being > kept active. > We're using a managed service and beleive he's been hit with an email about > excessive connections to the DB (where they've been dropped but the > connection hasn't been killed). > > I've not really done any web development so think it's time to do so [?] > dave. > > > On 9 December 2010 05:46, Jeremy Evans <[email protected]> wrote: > >> On Dec 8, 1:18 am, dave <[email protected]> wrote: >> > I have been hit my the DB administrator with a 5 minute connection >> > before disconnection. >> >> Hit him back? ;) >> >> > this means my program needs to be able to run a heartbeat to keep >> > things alive. >> > how do i do this? >> >> Thread.new{loop{sleep 60; DB.get(1)}} >> >> There's a reason I'm using 60 and not 300, and it has to do with the >> connection pool. >> >> > I don't really want to put a meaningless dataset statement in the >> > ensure or rescue part of my code as this is to handle valid crashes >> > and not issues where the remote server wants to kill the connection >> > due to inactivity. >> >> You don't really want to use ensure or rescue. You just want to make >> sure that a connection is used at least every 5 minutes. Hopefully >> your DBA will eventually realize that setting a 5 minute timeout is >> just going to cause more database load, as you will be issuing >> pointless queries just to keep the connection open. >> >> > I thought there would be a method call with it being a boolean or a >> > second / minute value to be passed that would be triggered to keep the >> > connection open within the sequel gem. >> >> Nope. I think the above code should suffice. >> >> Jeremy >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sequel-talk" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<sequel-talk%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/sequel-talk?hl=en. >> >> > -- You received this message because you are subscribed to the Google Groups "sequel-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/sequel-talk?hl=en.
<<347.png>>
