[Mongrel] Finding out on which port mongrel is running

Jens Kraemer kraemer at webit.de
Fri Aug 4 05:36:57 EDT 2006


On Fri, Aug 04, 2006 at 10:42:26AM +0200, Maximilian Schoefmann wrote:
> > On 03/08/06, Maximilian Schoefmann <schoefma at cip.ifi.lmu.de> wrote:
> >> What's the best way to find out on which port mongrel is running from
> >> within Rails?
> >
> > Why would you want to do this? If you set it up, you should know which
> > ports you've configured...
> 
> I want to invoke a maintenance method on all instances through a
> webinterface. To do this I do a local http call to the other mongrels from
> the current mongrel.
> The problem is of course, that the current mongrel gets a timeout when it
> tries to call itself (thus I need to know the port to be able to skip it).
> 
> I'm of course open for better ideas how to accomplish this

Maybe storing the port in an environment variable in the call to
mongrel_rails would work ?

something like:

MONGREL_PORT=9200 mongrel_rails start -p $MONGREL_PORT -e production \
-a 127.0.0.1 -c /yourapp

I think you could then access this via ENV['MONGREL_PORT']

Jens

-- 
webit! Gesellschaft für neue Medien mbH          www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer       kraemer at webit.de
Schnorrstraße 76                         Tel +49 351 46766  0
D-01069 Dresden                          Fax +49 351 46766 66


More information about the Mongrel-users mailing list