Configure an app to run on a different port (in development)

What’s the common wisdom/best-practices regarding configuring an app to
run on a different port while developing (say, 3001 instead of 3000)?

I’ve been searching the web for this over the past few days, and I’ve
found two kinds of solutions:

The first (as seen a few places on StackOverflow) is sort-of
monkey-patching Rails::Server.default_options to override the :Port
option.

Another is to put “#\ -p 3001” at the beginning of the “config.ru” file.

Anybody have any strong preference for either of these two methods, or
for a third that I haven’t found?

It seems to me that the ideal would be if there was a line I could add
to config/environments/development.rb , but I’m not sure what that
would be.

I’m particularly worried about potentially using a undocumented
interface that could go away at any time.

Alternatively, is there an argument out there that “modifying your app
to use something other than 3000 is bad, it’s better just to use the -p
argument”?

On Wed, Apr 8, 2015 at 3:25 PM, Brian S.
[email protected] wrote:

What’s the common wisdom/best-practices regarding configuring an app to
run on a different port while developing (say, 3001 instead of 3000)?

I’m particularly worried about potentially using a undocumented
interface that could go away at any time.

Alternatively, is there an argument out there that “modifying your app
to use something other than 3000 is bad, it’s better just to use the -p
argument”?

This seems utterly too trivial to be worrying about. For one thing it
depends on what server you’re using (webrick isn’t the only option).

If you don’t want to have to add the ‘-p 3001’ manually to whatever
you’re using just create a shell alias or script and be done with it.

Alternately, if you’re on a Mac, use Pow (http://pow.cx/) and ignore
the whole issue :slight_smile:

FWIW,

Hassan S. ------------------------ [email protected]

twitter: @hassan
Consulting Availability : Silicon Valley or remote