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

Iñaki Baz Castillo ibc at aliax.net
Tue Jan 5 06:33:29 EST 2010


El Martes, 5 de Enero de 2010, Iñaki Baz Castillo escribió:
>   before_fork do |server, worker|
>     `echo "before_fork $$" >> /tmp/kk`
>   end


> And this is the file output:
> 
>   before_fork 3447
>   after_fork  3456
>   before_fork 3454
>   before_fork 3463
>   after_fork  3464
>   after_fork  3472


Hummm, this could be something strange related to how `` works...

If I do the following:

  before_fork do |server, worker|
    `echo "before_fork $$" >> /tmp/kk`
     File.open("/tmp/kk", "a") do |f|
       f.puts "$$=#{$$}"
     end
  end

then I get:

  before_fork 11989
  $$=11977
  before_fork 11994
  $$=11977
  before_fork 12000
  $$=11977

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).





-- 
Iñaki Baz Castillo <ibc at aliax.net>


More information about the mongrel-unicorn mailing list