about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/unicorn.rb7
-rw-r--r--lib/unicorn/socket_helper.rb2
-rw-r--r--test/unit/test_server.rb4
3 files changed, 13 insertions, 0 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 72cda10..14e0e52 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -78,6 +78,13 @@ module Unicorn
         end
       end
     end
+
+    # returns an array of strings representing TCP listen socket addresses
+    # and Unix domain socket paths.  This is useful for use with
+    # Raindrops::Middleware under Linux: http://raindrops.bogomips.org/
+    def listener_names
+      HttpServer::LISTENERS.map { |io| SocketHelper.sock_name(io) }
+    end
   end
 
   # This is the process manager of Unicorn. This manages worker
diff --git a/lib/unicorn/socket_helper.rb b/lib/unicorn/socket_helper.rb
index 09085e5..9a4266d 100644
--- a/lib/unicorn/socket_helper.rb
+++ b/lib/unicorn/socket_helper.rb
@@ -136,6 +136,8 @@ module Unicorn
       end
     end
 
+    module_function :sock_name
+
     # casts a given Socket to be a TCPServer or UNIXServer
     def server_cast(sock)
       begin
diff --git a/test/unit/test_server.rb b/test/unit/test_server.rb
index 36333a0..41d3e02 100644
--- a/test/unit/test_server.rb
+++ b/test/unit/test_server.rb
@@ -283,5 +283,9 @@ class WebServerTest < Test::Unit::TestCase
     }
   end
 
+  def test_listener_names
+    assert_equal [ "127.0.0.1:#@port" ], Unicorn.listener_names
+  end
+
 end