[n00b] How to CONFIGURE port other then 3000?

Look in to mongrel_cluster. Usually we use it for clustering mongrels
in production (go figure) but you can use it to run multiple instances
mapped to different ports automatically. An example config would be

oh, wait, I'm dumb. You said three different apps.

I would just write a little wrapper around script/server. Not that hard.


By "wrapper" I meant a little shell script

$ cat bin/run_server
ruby script/server -p 3001

Now in your project when you run


it runs script/server on port 3001. Copy that file into each project
you want and change the port to be whatever.

So, tell them to run bin/run_server instead of script/server? Not
that hard. If they forget to, they'll know when mongrel tries to
start up.

If you're super paranoid though, just move script/server to some other
file, maybe script/rails_server, and save the wrapper file to
script/server. Then when people run that they actually get your
custom wrapper.


Yes, there is, and you already know about it. It's the -p option.

Here's what you're failing to understand. The web server is
independent from the app itself. So, you're going to need to
configure the web server, not the rails app. This means either
passing in an extra option to the server, or creating a config file in
mongrel's case.

You can change script/server to be
#!/usr/bin/env ruby
unless ARGV.include?("-p")
  ARGV << "-p"
  ARGV << "3001"
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'

which will start it up on port 3001 unless some other port is
specified. If that's not good enough for you, sorry.

Also, I didn't know that trick until two minutes ago. I just saw that
script/server requires commands/server. So I googled "rails commands
server" and the first result was
   Then I looked at
to see exactly how it was getting the port...and modified
script/server to do that. So this stuff is pretty easy to figure out
if you spend a few minutes exploring.