Thomas
2009-Dec-08 23:50 UTC
(Rails 2.3) Upstream mongrel cluster: how to find out mongrel instance (port) which handles request
For debugging purpose I find it helpful to see which mongrel out of an upstream cluster, specifically which port number, handles an actual request. For example, let the load balancer operate on port 3000 (development) and the upstream mongrel cluster operating on ports 4000 upto 4002, then I would like to see not only the port 3000 (eg. using request.host_with_port in a controller) but also the port number of the actual mongrel instance. With Rails 2.1 I used session.cgi to spot the mongrel port (4000, 4001 or 4002), however, I was not able to figure this out in Rails 2.3 which is using the rack middleware. Any idea, how to do it? Greetings and thanks! Thomas -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Kristian Hellquist
2009-Dec-09 08:46 UTC
Re: (Rails 2.3) Upstream mongrel cluster: how to find out mongrel instance (port) which handles request
Cant you just do `request.server_port'' in controller? 2009/12/9 Thomas <thomas.netsch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> For debugging purpose I find it helpful to see which mongrel out of an > upstream cluster, specifically which port number, handles an actual > request. For example, let the load balancer operate on port 3000 > (development) and the upstream mongrel cluster operating on ports 4000 > upto 4002, then I would like to see not only the port 3000 (eg. using > request.host_with_port in a controller) but also the port number of > the actual mongrel instance. > > With Rails 2.1 I used session.cgi to spot the mongrel port (4000, 4001 > or 4002), however, I was not able to figure this out in Rails 2.3 > which is using the rack middleware. > > Any idea, how to do it? > > Greetings and thanks! > Thomas > > -- > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thomas
2009-Dec-09 09:56 UTC
Re: (Rails 2.3) Upstream mongrel cluster: how to find out mongrel instance (port) which handles request
Hi Kristian, this also results in port number ''3000'', and not in the port number of the upstream mongrel. On 9 Dez., 09:46, Kristian Hellquist <kristian.hellqu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Cant you just do `request.server_port'' in controller? > > 2009/12/9 Thomas <thomas.net...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > > For debugging purpose I find it helpful to see which mongrel out of an > > upstream cluster, specifically which port number, handles an actual > > request. For example, let the load balancer operate on port 3000 > > (development) and the upstream mongrel cluster operating on ports 4000 > > upto 4002, then I would like to see not only the port 3000 (eg. using > > request.host_with_port in a controller) but also the port number of > > the actual mongrel instance. > > > With Rails 2.1 I used session.cgi to spot the mongrel port (4000, 4001 > > or 4002), however, I was not able to figure this out in Rails 2.3 > > which is using the rack middleware. > > > Any idea, how to do it? > > > Greetings and thanks! > > Thomas > > > -- > > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Kristian Hellquist
2009-Dec-09 13:06 UTC
Re: Re: (Rails 2.3) Upstream mongrel cluster: how to find out mongrel instance (port) which handles request
Does request.env.inspect gives you any hint? 2009/12/9 Thomas <thomas.netsch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Hi Kristian, this also results in port number ''3000'', and not in the > port number of the upstream mongrel. > > > On 9 Dez., 09:46, Kristian Hellquist <kristian.hellqu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> Cant you just do `request.server_port'' in controller? >> >> 2009/12/9 Thomas <thomas.net...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> >> >> >> > For debugging purpose I find it helpful to see which mongrel out of an >> > upstream cluster, specifically which port number, handles an actual >> > request. For example, let the load balancer operate on port 3000 >> > (development) and the upstream mongrel cluster operating on ports 4000 >> > upto 4002, then I would like to see not only the port 3000 (eg. using >> > request.host_with_port in a controller) but also the port number of >> > the actual mongrel instance. >> >> > With Rails 2.1 I used session.cgi to spot the mongrel port (4000, 4001 >> > or 4002), however, I was not able to figure this out in Rails 2.3 >> > which is using the rack middleware. >> >> > Any idea, how to do it? >> >> > Greetings and thanks! >> > Thomas >> >> > -- >> >> > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. >> > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. >> > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thomas
2009-Dec-09 20:56 UTC
Re: (Rails 2.3) Upstream mongrel cluster: how to find out mongrel instance (port) which handles request
This helped! Though, a bit strange, the only "hint" for the mongrel port is in request.env["rack.errors"] which is an IO object pointing the logfile of the mongrel. It is something like "/somepath/mongrel.400x.log". Hence request.env["rack.errors"].inspect[/mongrel\.\d+/] verboses the mongrel port of the request. Thanks, this solves my problem, Thomas On 9 Dez., 14:06, Kristian Hellquist <kristian.hellqu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Does request.env.inspect gives you any hint? > > 2009/12/9 Thomas <thomas.net...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > > Hi Kristian, this also results in port number ''3000'', and not in the > > port number of the upstream mongrel. > > > On 9 Dez., 09:46, Kristian Hellquist <kristian.hellqu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > >> Cant you just do `request.server_port'' in controller? > > >> 2009/12/9 Thomas <thomas.net...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > >> > For debugging purpose I find it helpful to see which mongrel out of an > >> > upstream cluster, specifically which port number, handles an actual > >> > request. For example, let the load balancer operate on port 3000 > >> > (development) and the upstream mongrel cluster operating on ports 4000 > >> > upto 4002, then I would like to see not only the port 3000 (eg. using > >> > request.host_with_port in a controller) but also the port number of > >> > the actual mongrel instance. > > >> > With Rails 2.1 I used session.cgi to spot the mongrel port (4000, 4001 > >> > or 4002), however, I was not able to figure this out in Rails 2.3 > >> > which is using the rack middleware. > > >> > Any idea, how to do it? > > >> > Greetings and thanks! > >> > Thomas > > >> > -- > > >> > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > >> > To post to this group, send email to rubyonrails-talk@googlegroups.com. > >> > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
ak
2009-Dec-24 23:41 UTC
Re: (Rails 2.3) Upstream mongrel cluster: how to find out mongrel instance (port) which handles request
Thomas, I''m still on Rails 2.1 and would like to do exactly what you were doing? What is the Rails 2.1 way? Call session.cgi.handler.listener.port ? Will that give the port number of the actual instance? On Dec 8, 3:50 pm, Thomas <thomas.net...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> For debugging purpose I find it helpful to see which mongrel out of an > upstream cluster, specifically which port number, handles an actual > request. For example, let the load balancer operate on port 3000 > (development) and the upstream mongrel cluster operating on ports 4000 > upto 4002, then I would like to see not only the port 3000 (eg. using > request.host_with_port in a controller) but also the port number of > the actual mongrel instance. > > With Rails 2.1 I used session.cgi to spot the mongrel port (4000, 4001 > or 4002), however, I was not able to figure this out in Rails 2.3 > which is using the rack middleware. > > Any idea, how to do it? > > Greetings and thanks! > Thomas-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thomas
2009-Dec-26 16:37 UTC
Re: (Rails 2.3) Upstream mongrel cluster: how to find out mongrel instance (port) which handles request
I was using the following lines in my _debug.html.erb partial: <% session.cgi.inspect.split(/,/).each{ |key| @mongrel_port = key if(key =~ /@port/)} %> <%= @mongrel_port %> Greetings, Thomas On 25 Dez., 00:41, ak <ajay.ka...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thomas, I''m still on Rails 2.1 and would like to do exactly what you > were doing? What is the Rails 2.1 way? Call > session.cgi.handler.listener.port ? Will that give the port number of > the actual instance? > > On Dec 8, 3:50 pm, Thomas <thomas.net...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > For debugging purpose I find it helpful to see which mongrel out of an > > upstream cluster, specifically which port number, handles an actual > > request. For example, let the load balancer operate on port 3000 > > (development) and the upstream mongrel cluster operating on ports 4000 > > upto 4002, then I would like to see not only the port 3000 (eg. using > > request.host_with_port in a controller) but also the port number of > > the actual mongrel instance. > > > With Rails 2.1 I used session.cgi to spot the mongrel port (4000, 4001 > > or 4002), however, I was not able to figure this out in Rails 2.3 > > which is using the rack middleware. > > > Any idea, how to do it? > > > Greetings and thanks! > > Thomas-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.