unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* Rack env rack.multiprocess true with single worker
@ 2012-10-18  6:33 Petteri Räty
  2012-10-18  7:53 ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Petteri Räty @ 2012-10-18  6:33 UTC (permalink / raw)
  To: unicorn list

Hi,
unicorn unconditionally sets rack.multiprocess to true in the Rack
environment. The Rack spec [0] says the following about the variable:

"true if an equivalent application object may be simultaneously invoked
by another process, false otherwise."

When unicorn is running with a single worker this does not hold so what
do you think about setting the variable to false when only a single
worker is configured? I want to use the variable to check if I can do a
HTTP call back to the application (long story) but currently with
unicorn and single worker this is not possible.

Regards,
Petteri

[0] http://rack.rubyforge.org/doc/files/SPEC.html
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Rack env rack.multiprocess true with single worker
  2012-10-18  6:33 Rack env rack.multiprocess true with single worker Petteri Räty
@ 2012-10-18  7:53 ` Eric Wong
  2012-10-18  8:52   ` Petteri Räty
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2012-10-18  7:53 UTC (permalink / raw)
  To: unicorn list

Petteri Räty <betelgeuse@gentoo.org> wrote:
> Hi,
> unicorn unconditionally sets rack.multiprocess to true in the Rack
> environment. The Rack spec [0] says the following about the variable:
> 
> "true if an equivalent application object may be simultaneously invoked
> by another process, false otherwise."
> 
> When unicorn is running with a single worker this does not hold so what
> do you think about setting the variable to false when only a single
> worker is configured? I want to use the variable to check if I can do a
> HTTP call back to the application (long story) but currently with
> unicorn and single worker this is not possible.

We cannot safely set rack.multiprocess=false.

Even if unicorn is started with a single worker, it is possible
to start more workers via SIGTTIN, and the first worker would
never see the change.


However, if you're certain nobody on your server will use SIGTTIN,
you can set the following anywhere in your unicorn config file:

	Unicorn::HttpRequest::DEFAULTS["rack.multiprocess"] = false

Changing the DEFAULTS constant has been and will remain supported
for as long as this project supports Rack 1.x (forever? :)


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.
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Rack env rack.multiprocess true with single worker
  2012-10-18  7:53 ` Eric Wong
@ 2012-10-18  8:52   ` Petteri Räty
  2012-10-18 17:38     ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Petteri Räty @ 2012-10-18  8:52 UTC (permalink / raw)
  To: mongrel-unicorn

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.

Regards,
Petteri
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Rack env rack.multiprocess true with single worker
  2012-10-18  8:52   ` Petteri Räty
@ 2012-10-18 17:38     ` Eric Wong
  2012-10-18 18:11       ` Devin Ben-Hur
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2012-10-18 17:38 UTC (permalink / raw)
  To: unicorn list

Petteri Räty <betelgeuse@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.
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Rack env rack.multiprocess true with single worker
  2012-10-18 17:38     ` Eric Wong
@ 2012-10-18 18:11       ` Devin Ben-Hur
  0 siblings, 0 replies; 5+ messages in thread
From: Devin Ben-Hur @ 2012-10-18 18:11 UTC (permalink / raw)
  To: mongrel-unicorn

On 10/18/2012 10:38 AM, Eric Wong wrote:
> Petteri Räty <betelgeuse@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`.
   split("\n").
   map{ |line| line.split(' ',4)[2].to_i }.
   select{ |ppid| ppid == Process.ppid }.size
end
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-10-18 18:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-18  6:33 Rack env rack.multiprocess true with single worker Petteri Räty
2012-10-18  7:53 ` Eric Wong
2012-10-18  8:52   ` Petteri Räty
2012-10-18 17:38     ` Eric Wong
2012-10-18 18:11       ` Devin Ben-Hur

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).