[Mongrel] Finding out on which port mongrel is running
zedshaw at zedshaw.com
Fri Aug 4 12:48:11 EDT 2006
On Thu, 2006-08-03 at 21:00 +0200, Maximilian Schoefmann wrote:
> Hi *,
> What's the best way to find out on which port mongrel is running from
> within Rails?
> I have a cluster of mongrels behind a balancer (Pen) behind a webserver
> In Rails,
> request.port return 80
> request.env['SERVER_PORT'] returns 3000 (the port of Pen)
> Any ideas?
First off, doing this "connect back to mongrel" in rails is bad news.
It'll lock up on you because Rails is locked while your making the
request so you deadlock.
Second, you should be doing this with an external monitor like monit. I
highly recommend monit. And since you're using mongrel_cluster you
should know what ports they're configured on.
But, you'll probably want to continue with your idea anyway, so go check
out handlers.rb StatsHandler and see how it's printing out stats. Every
handler has access to it's "listener". So the snippet:
results << table("settings", [
Is printing the host, port, and other setting for the handlers listener.
So, write a mongrel handler and you won't have to worry about rails
locking. The RDoc has more info like this.
Zed A. Shaw
http://www.railsmachine.com/ -- Need Mongrel support?
More information about the Mongrel-users