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