rack-mux 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rack/mux.rb +17 -15
- data/spec/spec_helper.rb +1 -0
- metadata +6 -6
data/lib/rack/mux.rb
CHANGED
@@ -2,7 +2,7 @@ require 'rack'
|
|
2
2
|
|
3
3
|
module Rack
|
4
4
|
class Mux
|
5
|
-
VERSION = '0.1.
|
5
|
+
VERSION = '0.1.2'
|
6
6
|
HEADER = 'X-Mux-Uri'
|
7
7
|
|
8
8
|
def initialize(app, options = {})
|
@@ -20,7 +20,7 @@ module Rack
|
|
20
20
|
|
21
21
|
def rackup
|
22
22
|
Thread.new(server_options) do |options|
|
23
|
-
Server.start(
|
23
|
+
Server.start(options)
|
24
24
|
end
|
25
25
|
|
26
26
|
wait_for_server
|
@@ -39,24 +39,26 @@ module Rack
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def find_port
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
loop do
|
43
|
+
port = rand(64510) + 1025
|
44
|
+
begin
|
45
|
+
TCPSocket.new(@host, port)
|
46
|
+
rescue Errno::ECONNREFUSED
|
47
|
+
return port
|
48
|
+
end
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
def wait_for_server
|
53
53
|
Timeout::timeout(30) do
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
loop do
|
55
|
+
begin
|
56
|
+
return TCPSocket.new(@host, @port)
|
57
|
+
rescue Errno::ECONNREFUSED
|
58
|
+
sleep 1
|
59
|
+
rescue => e
|
60
|
+
raise Error, e.message
|
61
|
+
end
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-mux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 31
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Burkert
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-04-28 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
163
|
requirements: []
|
164
164
|
|
165
165
|
rubyforge_project:
|
166
|
-
rubygems_version: 1.
|
166
|
+
rubygems_version: 1.6.2
|
167
167
|
signing_key:
|
168
168
|
specification_version: 3
|
169
169
|
summary: Multiplex multiple rack servers to the same app.
|