mizuno 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mizuno/choices.rb +6 -0
- data/lib/mizuno/rack_handler.rb +1 -3
- data/lib/mizuno/runner.rb +24 -15
- data/lib/mizuno/server.rb +15 -1
- data/lib/mizuno/version.rb +1 -1
- metadata +2 -2
data/lib/mizuno/choices.rb
CHANGED
data/lib/mizuno/rack_handler.rb
CHANGED
@@ -10,7 +10,6 @@ module Mizuno
|
|
10
10
|
class RackHandler < AbstractHandler
|
11
11
|
java_import 'java.io.FileInputStream'
|
12
12
|
java_import 'org.eclipse.jetty.continuation.ContinuationSupport'
|
13
|
-
java_import 'org.jruby.rack.servlet.RewindableInputStream'
|
14
13
|
|
15
14
|
# Regex for splitting on newlines.
|
16
15
|
NEWLINE = /\n/
|
@@ -133,8 +132,7 @@ module Mizuno
|
|
133
132
|
env['rack.run_once'] = false
|
134
133
|
|
135
134
|
# The input stream is a wrapper around the Java InputStream.
|
136
|
-
env['rack.input'] =
|
137
|
-
request.getInputStream).to_io.binmode
|
135
|
+
env['rack.input'] = @server.rewindable(request)
|
138
136
|
|
139
137
|
# Force encoding if we're on Ruby 1.9
|
140
138
|
env['rack.input'].set_encoding(Encoding.find("ASCII-8BIT")) \
|
data/lib/mizuno/runner.rb
CHANGED
@@ -226,15 +226,16 @@ module Mizuno
|
|
226
226
|
# error, false otherwise.
|
227
227
|
#
|
228
228
|
def Runner.wait_for_server(options, timeout = 120)
|
229
|
+
force_time_out_at = Time.now + timeout
|
230
|
+
sleep_interval_for_next_retry = 0.1
|
231
|
+
|
229
232
|
begin
|
230
|
-
|
231
|
-
|
232
|
-
response = http.get("/")
|
233
|
-
return(response.code.to_i < 500)
|
234
|
-
end
|
233
|
+
response = connect_to_server_as_client(options, timeout)
|
234
|
+
return(response.code.to_i < 500)
|
235
235
|
rescue Errno::ECONNREFUSED => error
|
236
|
-
return(false)
|
237
|
-
sleep(
|
236
|
+
return(false) if (Time.now > force_time_out_at)
|
237
|
+
sleep(sleep_interval_for_next_retry)
|
238
|
+
sleep_interval_for_next_retry *= 2
|
238
239
|
retry
|
239
240
|
rescue => error
|
240
241
|
puts "HTTP Error '#{error}'"
|
@@ -248,15 +249,14 @@ module Mizuno
|
|
248
249
|
# responding, returns false.
|
249
250
|
#
|
250
251
|
def Runner.wait_for_server_to_die(options, timeout = 120)
|
252
|
+
force_time_out_at = Time.now + timeout
|
253
|
+
sleep_interval_for_next_retry = 0.1
|
254
|
+
|
251
255
|
begin
|
252
|
-
while(
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
puts "**** (die) response: #{response}"
|
257
|
-
end
|
258
|
-
timeout -= 0.5
|
259
|
-
sleep(0.5)
|
256
|
+
while (Time.now < force_time_out_at)
|
257
|
+
connect_to_server_as_client(options, timeout)
|
258
|
+
sleep(sleep_interval_for_next_retry)
|
259
|
+
sleep_interval_for_next_retry *= 2
|
260
260
|
end
|
261
261
|
return(false)
|
262
262
|
rescue Errno::ECONNREFUSED => error
|
@@ -267,6 +267,15 @@ module Mizuno
|
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
270
|
+
def Runner.connect_to_server_as_client(server_options, timeout)
|
271
|
+
options = server_options.dup
|
272
|
+
options[:host] = '127.0.0.1' if options[:host] == "0.0.0.0"
|
273
|
+
Net::HTTP.start(options[:host], options[:port]) do |http|
|
274
|
+
http.read_timeout = timeout
|
275
|
+
http.get("/")
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
270
279
|
#
|
271
280
|
# Exit with a message and a status value.
|
272
281
|
#
|
data/lib/mizuno/server.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
# deprecation notice and remove it in later versions.
|
3
3
|
|
4
4
|
require 'rack'
|
5
|
+
require 'rack/rewindable_input'
|
5
6
|
require 'mizuno'
|
6
7
|
Mizuno.require_jars(%w(jetty-continuation jetty-http jetty-io jetty-jmx
|
7
8
|
jetty-security jetty-server jetty-util servlet-api
|
@@ -16,6 +17,7 @@ module Mizuno
|
|
16
17
|
class Server
|
17
18
|
java_import 'org.eclipse.jetty.server.nio.SelectChannelConnector'
|
18
19
|
java_import 'org.eclipse.jetty.util.thread.QueuedThreadPool'
|
20
|
+
java_import 'org.jruby.rack.servlet.RewindableInputStream'
|
19
21
|
|
20
22
|
attr_accessor :logger
|
21
23
|
|
@@ -98,7 +100,7 @@ module Mizuno
|
|
98
100
|
$stderr.printf("%s listening on %s:%s\n", version,
|
99
101
|
connector.host, connector.port) unless options[:quiet]
|
100
102
|
|
101
|
-
# If we're
|
103
|
+
# If we're embedded, we're done.
|
102
104
|
return if options[:embedded]
|
103
105
|
|
104
106
|
# Stop the server when we get The Signal.
|
@@ -126,5 +128,17 @@ module Mizuno
|
|
126
128
|
def version
|
127
129
|
"Mizuno #{Mizuno::VERSION} (Jetty #{Java.org.eclipse.jetty.server.Server.getVersion})"
|
128
130
|
end
|
131
|
+
|
132
|
+
#
|
133
|
+
# Wraps the Java InputStream for the level of Rack compliance
|
134
|
+
# desired.
|
135
|
+
#
|
136
|
+
def rewindable(request)
|
137
|
+
input = request.getInputStream
|
138
|
+
|
139
|
+
@options[:rewindable] ?
|
140
|
+
Rack::RewindableInput.new(input.to_io.binmode) :
|
141
|
+
RewindableInputStream.new(input).to_io.binmode
|
142
|
+
end
|
129
143
|
end
|
130
144
|
end
|
data/lib/mizuno/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mizuno
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|