rack-mongrel2 0.2.3 → 0.2.4
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/README.md +28 -0
- data/lib/mongrel2.rb +1 -1
- data/lib/mongrel2/connection.rb +9 -5
- data/lib/rack/handler/mongrel2.rb +4 -3
- data/rack-mongrel2.gemspec +2 -2
- metadata +5 -5
data/README.md
CHANGED
@@ -22,6 +22,34 @@ I wrote this because I wanted to learn Mongrel2, and I didn't like what was out
|
|
22
22
|
|
23
23
|
Check out the blog post too: http://blog.darkhax.com/2010/10/26/deploying-your-ruby-app-with-mongrel2
|
24
24
|
|
25
|
+
## Advanced setup
|
26
|
+
|
27
|
+
### Using custom send and receive socket values
|
28
|
+
|
29
|
+
The Mongrel2 rack handler defaults the receive socket to `tcp://127.0.0.1:9997` and the send socket to `tcp://127.0.0.1:9996`.
|
30
|
+
|
31
|
+
To use different values set the `RACK_MONGREL2_RECV` and `RACK_MONGREL2_SEND` environment variables. For example:
|
32
|
+
|
33
|
+
export RACK_MONGREL2_RECV=<mongrel2 handler send_spec value>
|
34
|
+
export RACK_MONGREL2_SEND=<mongrel2 handler recv_spec value>
|
35
|
+
export RACK_MONGREL2_UUID=<mongrel2 handler send_ident value>
|
36
|
+
rails server Mongrel2
|
37
|
+
|
38
|
+
If for example your Mongrel2 handler configuration contains:
|
39
|
+
|
40
|
+
...
|
41
|
+
recv_spec='tcp://127.0.0.1:7771'
|
42
|
+
send_spec='tcp://127.0.0.1:7772',
|
43
|
+
send_ident='42ffdda3-d151-41b1-923f-899ef6fc530a',
|
44
|
+
...
|
45
|
+
|
46
|
+
Then you will need to start your Rails application using:
|
47
|
+
|
48
|
+
export RACK_MONGREL2_RECV=tcp://127.0.0.1:7772
|
49
|
+
export RACK_MONGREL2_SEND=tcp://127.0.0.1:7771
|
50
|
+
export RACK_MONGREL2_UUID=42ffdda3-d151-41b1-923f-899ef6fc530a
|
51
|
+
rails server Mongrel2
|
52
|
+
|
25
53
|
## Thanks!
|
26
54
|
|
27
55
|
* [Kevin Williams](https://github.com/kevwil) for PULL, specs, and other things.
|
data/lib/mongrel2.rb
CHANGED
data/lib/mongrel2/connection.rb
CHANGED
@@ -4,17 +4,21 @@ require 'mongrel2/response'
|
|
4
4
|
|
5
5
|
module Mongrel2
|
6
6
|
class Connection
|
7
|
-
|
7
|
+
@context = nil
|
8
|
+
|
9
|
+
def self.context
|
10
|
+
@context ||= ZMQ::Context.new(1)
|
11
|
+
end
|
8
12
|
|
9
13
|
def initialize(uuid, sub, pub)
|
10
14
|
@uuid, @sub, @pub = uuid, sub, pub
|
11
15
|
|
12
16
|
# Connect to receive requests
|
13
|
-
@reqs =
|
17
|
+
@reqs = self.class.context.socket(ZMQ::PULL)
|
14
18
|
@reqs.connect(sub)
|
15
19
|
|
16
20
|
# Connect to send responses
|
17
|
-
@resp =
|
21
|
+
@resp = self.class.context.socket(ZMQ::PUB)
|
18
22
|
@resp.connect(pub)
|
19
23
|
@resp.setsockopt(ZMQ::IDENTITY, uuid)
|
20
24
|
end
|
@@ -32,7 +36,7 @@ module Mongrel2
|
|
32
36
|
|
33
37
|
def close
|
34
38
|
# I think I should be able to just close the context
|
35
|
-
|
39
|
+
self.class.context.close rescue nil
|
36
40
|
end
|
37
41
|
end
|
38
|
-
end
|
42
|
+
end
|
@@ -7,8 +7,8 @@ module Rack
|
|
7
7
|
class << self
|
8
8
|
def run(app, options = {})
|
9
9
|
options = {
|
10
|
-
:recv => 'tcp://127.0.0.1:9997'
|
11
|
-
:send => 'tcp://127.0.0.1:9996'
|
10
|
+
:recv => ENV['RACK_MONGREL2_RECV'] || 'tcp://127.0.0.1:9997',
|
11
|
+
:send => ENV['RACK_MONGREL2_SEND'] || 'tcp://127.0.0.1:9996',
|
12
12
|
:uuid => ENV['RACK_MONGREL2_UUID']
|
13
13
|
}.merge(options)
|
14
14
|
|
@@ -42,6 +42,7 @@ module Rack
|
|
42
42
|
'rack.run_once' => false,
|
43
43
|
'mongrel2.pattern' => req.headers['PATTERN'],
|
44
44
|
'REQUEST_METHOD' => req.headers['METHOD'],
|
45
|
+
'CONTENT_TYPE' => req.headers['content-type'],
|
45
46
|
'SCRIPT_NAME' => script_name,
|
46
47
|
'PATH_INFO' => req.headers['PATH'].gsub(script_name, ''),
|
47
48
|
'QUERY_STRING' => req.headers['QUERY'] || ''
|
@@ -66,4 +67,4 @@ module Rack
|
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
69
|
-
end
|
70
|
+
end
|
data/rack-mongrel2.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'rack-mongrel2'
|
16
|
-
s.version = '0.2.
|
17
|
-
s.date = '2011-
|
16
|
+
s.version = '0.2.4'
|
17
|
+
s.date = '2011-08-23'
|
18
18
|
s.rubyforge_project = 'rack-mongrel2'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-mongrel2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Huckstep
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-08-23 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
requirements: []
|
158
158
|
|
159
159
|
rubyforge_project: rack-mongrel2
|
160
|
-
rubygems_version: 1.6.
|
160
|
+
rubygems_version: 1.6.2
|
161
161
|
signing_key:
|
162
162
|
specification_version: 2
|
163
163
|
summary: The only Mongrel2 Rack handler you'll ever need.
|