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].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.