ajp-rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/NEWS.en CHANGED
@@ -1,6 +1,9 @@
1
1
  = NEWS
2
+ == 0.0.3 (2006-01-25)
3
+ * The `0.3th' release.
4
+ * Sticky session support.
2
5
  == 0.0.2 (2006-01-24)
3
6
  Status: unstable
4
7
  * The `0th' release to be reviewed by "2nd Rails Meeting @ Tokyo".
5
- * The first release will be done in the last week of Jan, 2006. This
6
- will be include the result of the review.
8
+ * The first release -- v.0.1.0 -- will be done by the end of Jan, 2006.
9
+ This will be include the result of the review.
data/NEWS.ja CHANGED
@@ -1,6 +1,9 @@
1
1
  = NEWS
2
+ == 0.0.3 (2006-01-25)
3
+ * ����äȽ���`��0.3��'��꡼��
4
+ * Sticky session�򥵥ݡ���
2
5
  == 0.0.2 (2006-01-24)
3
6
  ����: �԰���
4
7
  * Rails�ٶ���@����ǥ�ӥ塼���Ƥ�餦����ˡ�`������'��꡼����
5
- * ����꡼����2006ǯ1��ǽ����Τ����ˤ���ͽ�ꡣ��ӥ塼���Ƥ��ä�
8
+ * ����꡼��(0.1.0)��2006ǯ1��ǽ����Τ����ˤ���ͽ�ꡣ��ӥ塼���Ƥ��ä�
6
9
  ��̤�ȿ�Ǥ�����������
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "ajp-rails"
3
- spec.version = "0.0.2"
3
+ spec.version = "0.0.3"
4
4
  spec.required_ruby_version = ">= 1.8.3"
5
5
  spec.add_dependency('ruby-ajp', '>= 0.2.0')
6
6
  spec.add_dependency('rails', '>= 0.14')
@@ -14,7 +14,20 @@ class AjpRailsDispatcher < Dispatcher
14
14
  request = AjpRailsRequest.new(ajp_req, session_options, server_environments)
15
15
  response = AjpRailsResponse.new
16
16
  prepare_application
17
- ActionController::Routing::Routes.recognize!(request).process(request, response).to_ajp_response(ajp_req.output_cookies)
17
+ ActionController::Routing::Routes.recognize!(request).process(request, response)
18
+ ajp_req.output_cookies.each do |cookie|
19
+ if cookie.name == 'JSESSIONID'
20
+ case cookie.value
21
+ when String
22
+ cookie.value << '.' << server_environments['LOAD_BALANCE_ID']
23
+ when Array
24
+ cookie.value.each do |item|
25
+ item << '.' << server_environments['LOAD_BALANCE_ID']
26
+ end
27
+ end
28
+ end
29
+ end
30
+ response.to_ajp_response(ajp_req.output_cookies)
18
31
  rescue Object => exception
19
32
  puts exception.message + ":" + exception.backtrace.join("\n")
20
33
  failsafe_response(500) do
@@ -50,6 +50,8 @@ OPTION_NAMES_TO_INTERNAL_NAMES = {
50
50
  'directory' => 'APP_DIRECTORY',
51
51
  'prefix' => 'DISPATCHER_PREFIX',
52
52
  'suffix' => 'DISPATCHER_SUFFIX',
53
+ 'jvm-route' => 'LOAD_BALANCE_ID',
54
+ 'serverid' => 'LOAD_BALANCE_ID',
53
55
  'daemon' => 'IS_DAEMON'
54
56
  }
55
57
 
@@ -105,6 +107,20 @@ def parse_options
105
107
  "The suffix of the ajp-mounted URLs.") { |v|
106
108
  cmd_opts[OPTION_NAMES_TO_INTERNAL_NAMES['suffix']] = v
107
109
  }
110
+ parser.on('--serverid=ID',
111
+ "The unique ID to identify this rails process," +
112
+ " which is for sticky session. The ID can contain only" +
113
+ " [a-z][A-Z][0-9], and case insensitive.") { |id|
114
+ raise ArgumentError, 'Server ID can contain only [a-z][A-Z][0-9].' unless
115
+ /\A[[:alnum:]]+\Z/ =~ id
116
+ cmd_opts[OPTION_NAMES_TO_INTERNAL_NAMES['serverid']] = id
117
+ }
118
+ parser.on('--jvm-route=ID',
119
+ "This is equal to --serverid") { |id|
120
+ raise ArgumentError, 'Server ID can contain only [a-z][A-Z][0-9].' unless
121
+ /\A[[:alnum:]]+\Z/ =~ id
122
+ cmd_opts[OPTION_NAMES_TO_INTERNAL_NAMES['jvm-route']] = id
123
+ }
108
124
  parser.on('--daemon', "Makes Rails run as a daemon") {|v|
109
125
  cmd_opts[OPTION_NAMES_TO_INTERNAL_NAMES['daemon']] = v
110
126
  }
@@ -80,6 +80,20 @@ class AjpRailsRequest < ActionController::AbstractRequest
80
80
  @server_environments = server_environments
81
81
  @session_options['session_path'] ||= @server_environments['APP_LOCATION']
82
82
 
83
+ if server_environments['LOAD_BALANCE_ID'] and @req.cookies['JSESSIONID']
84
+ balance_id = server_environments['LOAD_BALANCE_ID']
85
+ @req.cookies['JSESSIONID'].each do |value|
86
+ case value
87
+ when String
88
+ value.gsub!(/\.#{Regexp.escape(balance_id)}\Z/, '')
89
+ when Array
90
+ value.each do |entry|
91
+ entry.gsub!(/\.#{Regexp.escape(balance_id)}\Z/, '')
92
+ end
93
+ end
94
+ end
95
+ end
96
+
83
97
  # simulates environment hash.
84
98
  @env = self.class.instance_method(:environment).bind(self)
85
99
  # Object#method is overridden by AbstractRequest#method
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: ajp-rails
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.2
7
- date: 2006-01-24 00:00:00 +09:00
6
+ version: 0.0.3
7
+ date: 2006-01-25 00:00:00 +09:00
8
8
  summary: Ruby on Rails Runner, which uses AJP(Apache JServ Protocol) to cooperate with a HTTPd, instead of CGI or FastCGI
9
9
  require_paths:
10
10
  - lib