我看到一些奇怪的行为,当我运行Rails服务器rails s -e [env]
(双**添加了强调):什么能导致`rails s`忽略-e开关?
~/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
其结果是,-e
开关被忽略。
的没有提到在那里将被覆盖的任何情况。命令行帮助说-e Specifies the environment to run this server under test/development/production).
好的。
我真的认为这是几个星期前,做工精细(已经有一段时间了,我开始上那箱督促服务器),所以我可能已经改变的东西,打破了这一点,但什么?我检查了我在那里用=
代替==
,但没有发现任何地方。不要认为这将解释这一点。
更新:约翰正确地指出它是-e [env]
。我首先尝试了相同的结果,然后尝试-e=[env]
。正确的方法(仍然会产生不正确的结果):
~/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
这是奇怪的是,在它自己的运行轨道小号带来了测试环境,而不是发展,就是默认行为。你可以尝试设置RAILS_ENV环境变量,这是普遍尊重整个轨道,并看看会发生什么:'$ RAILS_ENV =生产钢轨s' – 2012-02-03 22:30:07