From c8d369a6599480dd682ef17543ed31c758ec9b46 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 15 Aug 2018 10:25:00 +1000 Subject: [PATCH] DEV: support -p in `rails s` if you need to specify port --- bin/rails | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/rails b/bin/rails index 04b8e02fe18..5481cad3fec 100755 --- a/bin/rails +++ b/bin/rails @@ -1,7 +1,12 @@ #!/usr/bin/env ruby if !ENV["RAILS_ENV"] && (ARGV[0] == "s" || ARGV[0] == "server") - ENV["UNICORN_PORT"] = "3000" + ENV["UNICORN_PORT"] ||= "3000" + + if ARGV[1] == "-p" && (port = ARGV[2].to_i) > 0 + ENV["UNICORN_PORT"] = port.to_s + end + ENV["RAILS_LOGS_STDOUT"] ||= "1" exec File.expand_path("unicorn", __dir__) end