mizuno 0.4.0 → 0.4.1

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/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
data/README.markdown CHANGED
@@ -17,7 +17,8 @@ Mizuno is the fastest option for Rack applications on JRuby:
17
17
  Jetty (via jruby-rack): 2011.67 req/s (mean)
18
18
  Mongrel: 1479.15 req/sec (mean)
19
19
 
20
- Mizuno also supports asynchronous request handling.
20
+ Mizuno also supports asynchronous request handling, via the Java Servlet
21
+ 3.0 asynchronous processing mechanism
21
22
 
22
23
  All the speed comes from Jetty 7; Mizuno just ties it to Rack through
23
24
  JRuby's Ruby/Java integration layer.
@@ -28,10 +29,9 @@ Rack application for installation in a Java web container.
28
29
 
29
30
  There's also a few features that I have yet to implement:
30
31
 
31
- 1. Integrate the cometd servlet to provide Comet/Bayeux.
32
- 2. Route Jetty's logs into Rack::Logger.
33
- 3. Add hooks for realtime monitoring of server performance.
34
- 4. Add the ability to run multiple Rack apps in a single JVM.
32
+ 1. Route Jetty's logs into Rack::Logger.
33
+ 2. Add hooks for realtime monitoring of server performance.
34
+ 3. Fast restarts of the Rack application.
35
35
 
36
36
  Mizuno is licensed under the Apache Public License, version 2.0; see
37
37
  the LICENSE file for details, and was developed on behalf of
data/Rakefile ADDED
@@ -0,0 +1,80 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'open-uri'
3
+ require 'nokogiri'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
8
+
9
+ namespace :jetty do
10
+ desc "Grab the latest Jetty from its Maven repository."
11
+ task :update do
12
+ # Manipulate files under the gem root.
13
+ base_path = File.dirname(__FILE__)
14
+ jar_path = File.join(base_path, 'lib', 'java')
15
+
16
+ # Information about the Maven repository.
17
+ group = "org.eclipse.jetty"
18
+ artifact = "jetty-distribution"
19
+ repository = 'http://repo1.maven.org/maven2/'
20
+
21
+ # Parse Maven metadata and get the latest release version.
22
+ url = File.join(repository, group.gsub('.', '/'), artifact)
23
+ metadata_url = File.join(url, 'maven-metadata.xml')
24
+ metadata = Nokogiri::XML(open(metadata_url))
25
+ release = metadata.at_xpath('//release').content
26
+ puts "Latest Jetty release is #{release}"
27
+
28
+ # Download the latest version to our tmpdir.
29
+ filename = "#{artifact}-#{release}.tar.gz"
30
+ artifact_url = File.join(url, release, filename)
31
+ tempfile = File.join(base_path, 'tmp', filename)
32
+ if(File.exists?(tempfile))
33
+ puts "Using cached #{tempfile}"
34
+ else
35
+ File.open(tempfile, "wb") { |f|
36
+ f.write(open(artifact_url).read) }
37
+ puts "Downloaded to #{tempfile}"
38
+ end
39
+
40
+ # Inventory contents of the tarball we picked up.
41
+ inventory = `tar tzf #{tempfile}`.split(/\n/)
42
+
43
+ # Find replacements from our downloaded tarball for each of our jars.
44
+ replacements = {}
45
+ Dir.entries(jar_path).each do |entry|
46
+ next unless (entry =~ /^\w.*\d\.jar$/)
47
+ name = entry.sub(/\-\d.*$/, '')
48
+ matcher = /\/#{name}\-[^\/]+\d\.jar$/
49
+ archive_file = inventory.find { |i| i =~ matcher }
50
+ raise("Archive missing replacement for #{entry}") \
51
+ unless archive_file
52
+ replacements[entry] = archive_file
53
+ end
54
+
55
+ # Extract replacements and verify that they aren't corrupted.
56
+ replacements.keys.each do |original|
57
+ replacement = replacements[original]
58
+ outfile = File.join(base_path, 'tmp',
59
+ File.basename(replacement))
60
+ system("tar xzOf #{tempfile} #{replacement} > #{outfile}") \
61
+ unless File.exists?(outfile)
62
+ system("jar tf #{outfile} >/dev/null 2>/dev/null")
63
+ raise("#{outfile} from #{tempfile} corrupt.") unless ($? == 0)
64
+ replacements[original] = outfile
65
+ end
66
+
67
+ # Remove old JARs, then add new JARs.
68
+ replacements.keys.each do |entry|
69
+ file = File.join(jar_path, entry)
70
+ puts "deleting: #{file}"
71
+ FileUtils.rm(file)
72
+ end
73
+ replacements.values.each do |entry|
74
+ file = File.join(jar_path, File.basename(entry))
75
+ puts "copying: #{file}"
76
+ FileUtils.move(entry, file)
77
+ end
78
+ puts "Update complete."
79
+ end
80
+ end
Binary file
@@ -68,19 +68,24 @@ module Mizuno
68
68
  puts "Listening on #{connector.getHost}:#{connector.getPort}"
69
69
  @server.start
70
70
 
71
+ # If we're embeded, we're done.
72
+ return if options[:embedded]
73
+
71
74
  # Stop the server when we get The Signal.
72
75
  trap("SIGINT") { @server.stop and exit }
73
76
 
74
77
  # Join with the server thread, so that currently open file
75
78
  # descriptors don't get closed by accident.
76
79
  # http://www.ruby-forum.com/topic/209252
77
- @server.join unless options[:embedded]
80
+ @server.join
78
81
  end
79
82
 
80
83
  #
81
84
  # Shuts down an embedded Jetty instance.
82
85
  #
83
86
  def self.stop
87
+ return unless @server
88
+ puts "Stopping Jetty..."
84
89
  @server.stop
85
90
  end
86
91
  end
@@ -88,3 +93,6 @@ end
88
93
 
89
94
  # Register ourselves with Rack when this file gets loaded.
90
95
  Rack::Handler.register 'mizuno', 'Mizuno::HttpServer'
96
+
97
+ # Ensure that we shutdown the server on exit.
98
+ at_exit { Mizuno::HttpServer.stop }
@@ -1,3 +1,5 @@
1
+ require 'stringio'
2
+
1
3
  #
2
4
  # Wraps a Rack application in a Java servlet.
3
5
  #
@@ -120,6 +122,14 @@ module Mizuno
120
122
  env['rack.multithread'] = true
121
123
  env['rack.run_once'] = false
122
124
 
125
+ # The input stream is a wrapper around the Java InputStream.
126
+ env['rack.input'] = request.getInputStream.to_io.binmode
127
+
128
+ # Force encoding if we're on Ruby 1.9
129
+ env['rack.input'].set_encoding(Encoding.find("ASCII-8BIT")) \
130
+ if env['rack.input'].respond_to?(:set_encoding)
131
+ # puts "**** rack.input.encoding: #{env['rack.input'].encoding}"
132
+
123
133
  # Populate the HTTP headers.
124
134
  request.getHeaderNames.each do |header_name|
125
135
  header = header_name.upcase.tr('-', '_')
@@ -133,9 +143,6 @@ module Mizuno
133
143
  env["CONTENT_LENGTH"] = env.delete("HTTP_CONTENT_LENGTH") \
134
144
  if env["HTTP_CONTENT_LENGTH"]
135
145
 
136
- # The input stream is a wrapper around the Java InputStream.
137
- env['rack.input'] = request.getInputStream.to_io
138
-
139
146
  # The output stream defaults to stderr.
140
147
  env['rack.errors'] ||= $stderr
141
148
 
data/mizuno.gemspec CHANGED
@@ -1,34 +1,34 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "mizuno"
3
- spec.version = "0.4.0"
3
+ spec.version = "0.4.1"
4
4
  spec.required_rubygems_version = Gem::Requirement.new(">= 1.2") \
5
5
  if spec.respond_to?(:required_rubygems_version=)
6
6
  spec.authors = [ "Don Werve" ]
7
7
  spec.description = 'Jetty-powered running shoes for JRuby/Rack.'
8
8
  spec.summary = 'Rack handler for Jetty 7 on JRuby. Features multithreading, event-driven I/O, and async support.'
9
9
  spec.email = 'don@madwombat.com'
10
+ # FIXME: We're not getting put in bin/
10
11
  spec.executables = [ "mizuno" ]
11
- spec.files = %w( .gitignore
12
+ spec.files = %w(.gitignore
12
13
  README.markdown
13
14
  LICENSE
15
+ Rakefile
16
+ Gemfile
14
17
  mizuno.gemspec
15
- lib/java/jetty-continuation-7.3.0.v20110203.jar
16
- lib/java/jetty-http-7.3.0.v20110203.jar
17
- lib/java/jetty-io-7.3.0.v20110203.jar
18
- lib/java/jetty-jmx-7.3.0.v20110203.jar
19
- lib/java/jetty-security-7.3.0.v20110203.jar
20
- lib/java/jetty-server-7.3.0.v20110203.jar
21
- lib/java/jetty-servlet-7.3.0.v20110203.jar
22
- lib/java/jetty-servlets-7.3.0.v20110203.jar
23
- lib/java/jetty-util-7.3.0.v20110203.jar
24
- lib/java/servlet-api-2.5.jar
18
+ tmp/.gitkeep
25
19
  lib/mizuno/http_server.rb
26
20
  lib/mizuno/rack_servlet.rb
27
21
  lib/mizuno.rb
28
- bin/mizuno )
22
+ bin/mizuno)
23
+ jars = Dir.entries("lib/java").grep(/\.jar$/)
24
+ spec.files.concat(jars.map { |j| "lib/java/#{j}" })
29
25
  spec.homepage = 'http://github.com/matadon/mizuno'
30
26
  spec.has_rdoc = false
31
27
  spec.require_paths = [ "lib" ]
32
28
  spec.rubygems_version = '1.3.6'
33
29
  spec.add_dependency('rack', '>= 1.0.0')
30
+ spec.add_development_dependency('rspec', '>= 2.7.0')
31
+ spec.add_development_dependency('rspec-core', '>= 2.7.0')
32
+ spec.add_development_dependency('json_pure', '>= 1.6.1')
33
+ spec.add_development_dependency('nokogiri')
34
34
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mizuno
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.0
5
+ version: 0.4.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Don Werve
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-13 00:00:00 +09:00
13
+ date: 2011-11-19 00:00:00 +09:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -24,6 +24,50 @@ dependencies:
24
24
  version: 1.0.0
25
25
  type: :runtime
26
26
  version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 2.7.0
36
+ type: :development
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec-core
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.7.0
47
+ type: :development
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: json_pure
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 1.6.1
58
+ type: :development
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: nokogiri
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ type: :development
70
+ version_requirements: *id005
27
71
  description: Jetty-powered running shoes for JRuby/Rack.
28
72
  email: don@madwombat.com
29
73
  executables:
@@ -36,21 +80,24 @@ files:
36
80
  - .gitignore
37
81
  - README.markdown
38
82
  - LICENSE
83
+ - Rakefile
84
+ - Gemfile
39
85
  - mizuno.gemspec
40
- - lib/java/jetty-continuation-7.3.0.v20110203.jar
41
- - lib/java/jetty-http-7.3.0.v20110203.jar
42
- - lib/java/jetty-io-7.3.0.v20110203.jar
43
- - lib/java/jetty-jmx-7.3.0.v20110203.jar
44
- - lib/java/jetty-security-7.3.0.v20110203.jar
45
- - lib/java/jetty-server-7.3.0.v20110203.jar
46
- - lib/java/jetty-servlet-7.3.0.v20110203.jar
47
- - lib/java/jetty-servlets-7.3.0.v20110203.jar
48
- - lib/java/jetty-util-7.3.0.v20110203.jar
49
- - lib/java/servlet-api-2.5.jar
86
+ - tmp/.gitkeep
50
87
  - lib/mizuno/http_server.rb
51
88
  - lib/mizuno/rack_servlet.rb
52
89
  - lib/mizuno.rb
53
90
  - bin/mizuno
91
+ - lib/java/jetty-continuation-8.0.4.v20111024.jar
92
+ - lib/java/jetty-http-8.0.4.v20111024.jar
93
+ - lib/java/jetty-io-8.0.4.v20111024.jar
94
+ - lib/java/jetty-jmx-8.0.4.v20111024.jar
95
+ - lib/java/jetty-security-8.0.4.v20111024.jar
96
+ - lib/java/jetty-server-8.0.4.v20111024.jar
97
+ - lib/java/jetty-servlet-8.0.4.v20111024.jar
98
+ - lib/java/jetty-servlets-8.0.4.v20111024.jar
99
+ - lib/java/jetty-util-8.0.4.v20111024.jar
100
+ - lib/java/servlet-api-3.0.jar
54
101
  has_rdoc: true
55
102
  homepage: http://github.com/matadon/mizuno
56
103
  licenses: []
@@ -75,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
122
  requirements: []
76
123
 
77
124
  rubyforge_project:
78
- rubygems_version: 1.4.2
125
+ rubygems_version: 1.5.1
79
126
  signing_key:
80
127
  specification_version: 3
81
128
  summary: Rack handler for Jetty 7 on JRuby. Features multithreading, event-driven I/O, and async support.
Binary file
Binary file
Binary file