On Thu, 9 Mar 2006, Ezra Zygmuntowicz wrote:

> 	Keep in mind that rails and fork don't get along very well. If you
> 	just plain fork like you wold in a normal ruby scrip[t you will get
> 	the Mysql has gone away error and your db connection will be borken.
> 	Here is a little hack that will let you get away with forking without
> 	losing your db connection in rails:
>
>
>
>  fork do

   # all open file handles duped

>    LongProcess.do_something(that_takes_a_long_time)
>    Kernel.exec "echo -n"

   # all duped file handled flushed and closed!

>  end
>
> 	That last Kernel.exec "echo -n" is the hack that will keep your db 
> connection from "going away"
>
>
> Cheers-
> -Ezra

also, forking while in a db transaction is __bad__ idea.  not to mention
fastcgi...

best to start an external job runner daemon and use it via drb.  one is
included in the rq source but it's a bit bundled... i coded it for exactly
the reasons the op has expressed.

kind regards.

-a

-- 
knowledge is important, but the much more important is the use toward which it
is put.  this depends on the heart and mine the one who uses it.
- h.h. the 14th dali lama