aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorkoshigoe <koshigoeb@gmail.com>2017-05-01 17:05:49 +0900
committerkoshigoe <koshigoeb@gmail.com>2017-05-01 21:28:47 +0900
commitc0928831697306c0a92d5e71f35e8e060a59907b (patch)
treebea1d90a9a636444f40869a21014f1c741768cc6 /railties/lib
parent7cb71c5ce37b7bc599de851d44eaa6a948daec03 (diff)
downloadrails-c0928831697306c0a92d5e71f35e8e060a59907b.tar.gz
rails-c0928831697306c0a92d5e71f35e8e060a59907b.tar.bz2
rails-c0928831697306c0a92d5e71f35e8e060a59907b.zip
CLI arg `--port` has precedence over env `PORT`.
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails/commands/server/server_command.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/railties/lib/rails/commands/server/server_command.rb b/railties/lib/rails/commands/server/server_command.rb
index 278fe63c51..cf3903f3ae 100644
--- a/railties/lib/rails/commands/server/server_command.rb
+++ b/railties/lib/rails/commands/server/server_command.rb
@@ -95,10 +95,11 @@ module Rails
module Command
class ServerCommand < Base # :nodoc:
+ DEFAULT_PORT = 3000
DEFAULT_PID_PATH = "tmp/pids/server.pid".freeze
class_option :port, aliases: "-p", type: :numeric,
- desc: "Runs Rails on the specified port.", banner: :port, default: 3000
+ desc: "Runs Rails on the specified port - defaults to 3000.", banner: :port
class_option :binding, aliases: "-b", type: :string,
desc: "Binds Rails to the specified IP - defaults to 'localhost' in development and '0.0.0.0' in other environments'.",
banner: :IP
@@ -184,7 +185,7 @@ module Rails
end
def port
- ENV.fetch("PORT", options[:port]).to_i
+ options[:port] || ENV.fetch("PORT", DEFAULT_PORT).to_i
end
def host