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 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.
@@ -10,5 +10,5 @@ end
10
10
 
11
11
  module Mongrel2
12
12
  JSON = Object.const_defined?('Yajl') ? ::Yajl::Parser : ::JSON
13
- VERSION = '0.2.3'
13
+ VERSION = '0.2.4'
14
14
  end
@@ -4,17 +4,21 @@ require 'mongrel2/response'
4
4
 
5
5
  module Mongrel2
6
6
  class Connection
7
- CTX = ZMQ::Context.new(1)
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 = CTX.socket(ZMQ::PULL)
17
+ @reqs = self.class.context.socket(ZMQ::PULL)
14
18
  @reqs.connect(sub)
15
19
 
16
20
  # Connect to send responses
17
- @resp = CTX.socket(ZMQ::PUB)
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
- CTX.close rescue nil
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' || ENV['RACK_MONGREL2_RECV'],
11
- :send => 'tcp://127.0.0.1:9996' || ENV['RACK_MONGREL2_SEND'],
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
@@ -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.3'
17
- s.date = '2011-04-09'
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: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
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-04-09 00:00:00 -06:00
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.0
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.