Rack env rack.multiprocess true with single worker

Devin Ben-Hur dbenhur at whitepages.com
Thu Oct 18 18:11:38 UTC 2012

On 10/18/2012 10:38 AM, Eric Wong wrote:
> Petteri Räty <betelgeuse at gentoo.org> wrote:
>> On 18.10.2012 10.53, Eric Wong wrote:
>>> Since a single process deployment is a corner-case in production
>>> deployments, I don't think it's worth the effort to jump through hoops
>>> and set rack.multiprocess=false automatically.
>> Do the workers currently know how many others there are? I am trying to
>> understand if you are saying that writing a patch would not be trivial.
>> If it's relative straightforward I might take a stab.
> No, workers don't keep track of other workers and it's not easy to
> support this.
> The workaround with the DEFAULTS hash is your best option.

I think's Eric's suggested workaround is right, it is a bunch of work to 
make workers track other workers to little benefit; but one could cheat 
and use ps to find sibling processes (children of the worker's parent 
which should be the unicorn master):

def num_workers
   `ps -ef`.
   map{ |line| line.split(' ',4)[2].to_i }.
   select{ |ppid| ppid == Process.ppid }.size

More information about the mongrel-unicorn mailing list