提交 306c14c4 编写于 作者: D David Cornu

Use the PORT environment variable for rails server

上级 15fd2586
* `rails server` will now honour the `PORT` environment variable
*David Cornu*
* Plugins generated using `rails plugin new` are now generated with the * Plugins generated using `rails plugin new` are now generated with the
version number set to 0.1.0. version number set to 0.1.0.
......
...@@ -86,7 +86,7 @@ def middleware ...@@ -86,7 +86,7 @@ def middleware
def default_options def default_options
super.merge({ super.merge({
Port: 3000, Port: ENV.fetch('PORT', 3000).to_i,
DoNotReverseLookup: true, DoNotReverseLookup: true,
environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup, environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup,
daemonize: false, daemonize: false,
......
...@@ -44,6 +44,13 @@ def test_environment_with_rack_env ...@@ -44,6 +44,13 @@ def test_environment_with_rack_env
end end
end end
def test_environment_with_port
switch_env "PORT", "1234" do
server = Rails::Server.new
assert_equal 1234, server.options[:Port]
end
end
def test_caching_without_option def test_caching_without_option
args = [] args = []
options = Rails::Server::Options.new.parse!(args) options = Rails::Server::Options.new.parse!(args)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册