diff options
author | David Cornu <davidjcornu@gmail.com> | 2015-08-17 18:02:35 +0000 |
---|---|---|
committer | David Cornu <davidjcornu@gmail.com> | 2015-08-18 08:43:11 -0400 |
commit | 306c14c41135dc8d308967821d0bb26cf4bb7ecd (patch) | |
tree | 886692f18eabd8d047b8586b864a76d51a6788d9 | |
parent | 15fd2586a89f27031adc5fca8e03149b3c494fdb (diff) | |
download | rails-306c14c41135dc8d308967821d0bb26cf4bb7ecd.tar.gz rails-306c14c41135dc8d308967821d0bb26cf4bb7ecd.tar.bz2 rails-306c14c41135dc8d308967821d0bb26cf4bb7ecd.zip |
Use the PORT environment variable for rails server
-rw-r--r-- | railties/CHANGELOG.md | 4 | ||||
-rw-r--r-- | railties/lib/rails/commands/server.rb | 2 | ||||
-rw-r--r-- | railties/test/commands/server_test.rb | 7 |
3 files changed, 12 insertions, 1 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 21adac272d..faf6846e4b 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* `rails server` will now honour the `PORT` environment variable + + *David Cornu* + * Plugins generated using `rails plugin new` are now generated with the version number set to 0.1.0. diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index c8fb58ab05..d3ea441f8e 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -86,7 +86,7 @@ module Rails def default_options super.merge({ - Port: 3000, + Port: ENV.fetch('PORT', 3000).to_i, DoNotReverseLookup: true, environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup, daemonize: false, diff --git a/railties/test/commands/server_test.rb b/railties/test/commands/server_test.rb index 7a063aeddf..3be4a74f74 100644 --- a/railties/test/commands/server_test.rb +++ b/railties/test/commands/server_test.rb @@ -44,6 +44,13 @@ class Rails::ServerTest < ActiveSupport::TestCase 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 args = [] options = Rails::Server::Options.new.parse!(args) |