I’m seeing some strange behavior when I run Rails server with rails s -e [env] (double ** added for emphasis):
~/app> rails s -e=**production**# << ok...v
=> Booting Mongrel # v huh?
=> Rails 3.1.1 application starting in **test** on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
^CExiting
~/app> rails s -e=**development**
=> Booting Mongrel
=> Rails 3.1.1 application starting in **test** on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
^CExiting
~/app> RAILS_ENV=**development** rails s
=> Booting Mongrel
=> Rails 3.1.1 application starting in **development** on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
^CExiting
~/app> RAILS_ENV=**production** rails s
=> Booting Mongrel
=> Rails 3.1.1 application starting in **production** on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
The upshot is that the -e switch is being ignored.
The Rails guide doesn’t mention any situations where it will be overriden. The command line help says -e Specifies the environment to run this server under test/development/production). OK.
I really think this was working fine a few weeks ago (been a while since I started a prod server on that box) so I may have changed something that broke this, but what? I checked for places where I was using = instead of == but didn’t find any. Don’t think that would explain this.
Update: John correctly points out that it is -e [env]. I tried that first with the same results then tried -e=[env]. The correct way (still produces incorrect result):
~/app> rails s -e production -p 5000
=> Booting Mongrel ^^^^^^^^^ vvvv
=> Rails 3.1.1 application starting in test on http://0.0.0.0:5000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Check that you don’t have the
RAILS_ENVenvironment variable set as it will override whatever you pass as a command line option.The relevant bit of the rails source ydoes this
optionsis populated from the command line arguments, so ifRAILS_ENVis already set your command line options have no effect.