'before_fork' is executed in parallel by two processes ¿?

Eric Wong normalperson at yhbt.net
Tue Jan 5 17:57:52 EST 2010

Iñaki Baz Castillo <ibc at aliax.net> wrote:
> El Martes, 5 de Enero de 2010, Eric Wong escribió:
> > > So I'm totally lost. However if I test my databases in "before_fork" then
> > > I  see N number of DB connections (N = workers num).
> > 
> > How are you testing the database?  `` or via Ruby code?
> I use Ruby Sequel ORM.
> I've also added the following code to before_fork:
>   File.open("/tmp/lalala", "ab") do |f|
>     f.puts "My PID is #{$$}"
>   end
> I confirm that there are two lines printed in that file when Unicorn starts 
> (being 2 the number of workers). Is it the expected behavior?

Yes, before_fork and after_fork are both called for every worker forked.

Eric Wong

More information about the mongrel-unicorn mailing list