On Mon, Jan 10, 2011 at 2:36 AM, Roland Swingler
<roland.swing...@gmail.com>wrote:

> Hmm,
>
> So I have now tried both the DB.disconnect in the passenger block, and
> attempting to use the after_connect proc to reconnect automatically,
> but neither of these help, so I don't think it can be because (or only
> because) of issues to do with passenger forking.
>

This definitely works, as I'm using it and it fixes the error you're seeing.
What file did you add the passenger block to?

Perhaps you have multiple connections open to mysql? You could try something
like:

  ObjectSpace.each_object(Sequel::Database){ |d| d.disconnect }

or

  Sequel::DATABASES.each{ |d| d.disconnect }

  Aman


> I'm going to try setting the read_timeout value to a higher number and
> see if that has any impact, but I'm at a bit of a loss at the moment.
>
> R
>
>
> On Jan 7, 7:21 pm, Aman Gupta <themastermi...@gmail.com> wrote:
> > On Fri, Jan 7, 2011 at 2:54 AM, Roland Swingler
> > <roland.swing...@gmail.com>wrote:
> >
> > > > This code looks like you are attempting to disconnect after the fork,
> > > > instead of before forking.  Also, you don't need to call
> > > > Sequel.connect again, just DB.disconnect should be enough.  But make
> > > > sure it is called before forking, not after.
> >
> > > Ah - so is reconnecting to the DB handled for me by the connection
> > > pool as soon as I try to use the Database object (I tried in the
> > > console and it seems to work that way)?
> >
> > > The problem here is that I don't think I have any way of running code
> > > before fork is called, because it isn't a Daemon I'm writing myself,
> > > but Passenger. As far as I can tell from the passenger documentation,
> > > this is the only point at which I can hook into the passenger forking/
> > > spawning method.
> >
> > I am using DB.disconnect
> > inside PhusionPassenger.on_event(:starting_worker_process) without any
> > issues.
> >
> >   Aman
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > I'm probably being really dense, but why is it important to disconnect
> > > before rather than after the fork?
> >
> > > AFAIK, the connection won't actually ever be used in the parent
> > > process (a passenger ApplicationSpawner), only in child processes -
> > > does this make a difference as to whether it matters whether you
> > > disconnect pre/post fork?
> >
> > > Maybe this is more of a issue for the passenger mailing list.
> >
> > > @Aaron
> > > > don't forget that there may be a stateful
> > > > firewall that is expiring state and denying packets (thus causing the
> > > > disconnect).
> >
> > > I don't think this is the problem because I have a rails app working
> > > on the same setup which works fine.
> >
> > > Thanks for everyone's help so far, much appreciated.
> >
> > > Cheers,
> > > Roland
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "sequel-talk" group.
> > > To post to this group, send email to sequel-t...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > sequel-talk+unsubscr...@googlegroups.com<sequel-talk%2bunsubscr...@googlegroups.com>
> <sequel-talk%2bunsubscr...@googlegr oups.com>
> > > .
> > > 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 sequel-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> sequel-talk+unsubscr...@googlegroups.com<sequel-talk%2bunsubscr...@googlegroups.com>
> .
> 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 sequel-t...@googlegroups.com.
To unsubscribe from this group, send email to 
sequel-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to