From a1c61a663dbeda29967614ead7cac018281ed9de Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 24 Apr 2009 15:00:40 -0700 Subject: configurator: "listen" directive more nginx-like The following specifications to bind port 8080 on all interfaces are now accepted in the configuration file: listen "8080" # (with quotes) listen 8080 # (without quotes) --- lib/unicorn/configurator.rb | 3 ++- test/unit/test_configurator.rb | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index bd06996..6f49905 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -297,6 +297,7 @@ module Unicorn # expands pathnames of sockets if relative to "~" or "~username" # expands "*:port and ":port" to "0.0.0.0:port" def expand_addr(address) #:nodoc + return "0.0.0.0:#{address}" if Integer === address return address unless String === address case address @@ -304,7 +305,7 @@ module Unicorn File.expand_path($1) when %r{\A~} File.expand_path(address) - when %r{\A\*:(\d+)\z} + when %r{\A(?:\*:)?(\d+)\z} "0.0.0.0:#$1" when %r{\A(.*):(\d+)\z} # canonicalize the name diff --git a/test/unit/test_configurator.rb b/test/unit/test_configurator.rb index 0baaa79..98f2db6 100644 --- a/test/unit/test_configurator.rb +++ b/test/unit/test_configurator.rb @@ -26,6 +26,8 @@ class TestConfigurator < Test::Unit::TestCase assert_equal "0.0.0.0:2007", meth.call('0.0.0.0:2007') assert_equal "0.0.0.0:2007", meth.call(':2007') assert_equal "0.0.0.0:2007", meth.call('*:2007') + assert_equal "0.0.0.0:2007", meth.call('2007') + assert_equal "0.0.0.0:2007", meth.call(2007) assert_match %r{\A\d+\.\d+\.\d+\.\d+:2007\z}, meth.call('1:2007') assert_match %r{\A\d+\.\d+\.\d+\.\d+:2007\z}, meth.call('2:2007') end -- cgit v1.2.3-24-ge0c7