puma 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.3
4
+ - rbx
5
+ - jruby
data/History.txt CHANGED
@@ -1,3 +1,18 @@
1
+ === 1.3.0 / 2012-05-08
2
+
3
+ * 2 minor features:
4
+ * Return valid Rack responses (passes Lint) from status server
5
+ * Add -I option to specify $LOAD_PATH directories
6
+
7
+ * 4 bug fixes:
8
+ * Don't join the server thread inside the signal handle. Fixes #94
9
+ * Make NullIO#read mimic IO#read
10
+ * Only stop the status server if it's started. Fixes #84
11
+ * Set RACK_ENV early in cli also. Fixes #78
12
+
13
+ * 1 new contributer:
14
+ * Jesse Cooke
15
+
1
16
  === 1.2.2 / 2012-04-28
2
17
 
3
18
  * 4 bug fixes:
data/Manifest.txt CHANGED
@@ -1,3 +1,4 @@
1
+ .travis.yml
1
2
  COPYING
2
3
  Gemfile
3
4
  History.txt
@@ -56,6 +57,7 @@ test/test_config.rb
56
57
  test/test_http10.rb
57
58
  test/test_http11.rb
58
59
  test/test_integration.rb
60
+ test/test_null_io.rb
59
61
  test/test_persistent.rb
60
62
  test/test_puma_server.rb
61
63
  test/test_rack_handler.rb
data/Rakefile CHANGED
@@ -9,12 +9,13 @@ Hoe.plugin :git
9
9
  HOE = Hoe.spec "puma" do
10
10
  self.rubyforge_name = 'puma'
11
11
  self.readme_file = "README.md"
12
- self.urls = %w!http://puma.io http://github.com/puma/puma!
12
+ self.urls = %w!http://puma.io https://github.com/puma/puma!
13
13
 
14
14
  developer 'Evan Phoenix', 'evan@phx.io'
15
15
 
16
16
  spec_extras[:extensions] = ["ext/puma_http11/extconf.rb"]
17
17
  spec_extras[:executables] = ['puma', 'pumactl']
18
+ spec_extras[:homepage] = self.urls.first
18
19
 
19
20
  require_ruby_version ">= 1.8.7"
20
21
 
@@ -6,6 +6,7 @@ module Puma
6
6
  @cli = cli
7
7
  @auth_token = nil
8
8
  end
9
+ OK_STATUS = '{ "status": "ok" }'.freeze
9
10
 
10
11
  attr_accessor :auth_token
11
12
 
@@ -16,34 +17,39 @@ module Puma
16
17
 
17
18
  def call(env)
18
19
  unless authenticate(env)
19
- return [403, {}, ["Invalid auth token"]]
20
+ return rack_response(403, 'Invalid auth token', 'text/plain')
20
21
  end
21
22
 
22
23
  case env['PATH_INFO']
23
24
  when "/stop"
24
25
  @server.stop
25
- return [200, {}, ['{ "status": "ok" }']]
26
+ return rack_response(200, OK_STATUS)
26
27
 
27
28
  when "/halt"
28
29
  @server.halt
29
- return [200, {}, ['{ "status": "ok" }']]
30
+ return rack_response(200, OK_STATUS)
30
31
 
31
32
  when "/restart"
32
33
  if @cli and @cli.restart_on_stop!
33
34
  @server.begin_restart
34
35
 
35
- return [200, {}, ['{ "status": "ok" }']]
36
+ return rack_response(200, OK_STATUS)
36
37
  else
37
- return [200, {}, ['{ "status": "not configured" }']]
38
+ return rack_response(200, '{ "status": "not configured" }')
38
39
  end
39
40
 
40
41
  when "/stats"
41
42
  b = @server.backlog
42
43
  r = @server.running
43
- return [200, {}, ["{ \"backlog\": #{b}, \"running\": #{r} }"]]
44
+ return rack_response(200, %Q!{ "backlog": #{b}, "running": #{r} }!)
44
45
  end
45
46
 
46
- [404, {}, ["Unsupported action"]]
47
+ rack_response 404, "Unsupported action", 'text/plain'
48
+ end
49
+
50
+ private
51
+ def rack_response(status, body, content_type='application/json')
52
+ [status, { 'Content-Type' => content_type, 'Content-Length' => body.length.to_s }, [body]]
47
53
  end
48
54
  end
49
55
  end
data/lib/puma/cli.rb CHANGED
@@ -53,6 +53,8 @@ module Puma
53
53
  remove.each do |k|
54
54
  ENV.delete k
55
55
  end
56
+
57
+ ENV['RACK_ENV'] ||= "development"
56
58
  end
57
59
 
58
60
  def restart_on_stop!
@@ -167,6 +169,10 @@ module Puma
167
169
  @options[:config_file] = arg
168
170
  end
169
171
 
172
+ o.on "-I", "--include PATH", "Specify $LOAD_PATH directories" do |arg|
173
+ $LOAD_PATH.unshift(*arg.split(':'))
174
+ end
175
+
170
176
  o.on "-p", "--port PORT", "Define what port TCP port to bind to",
171
177
  "Use -b for more advanced options" do |arg|
172
178
  @options[:binds] << "tcp://#{Configuration::DefaultTCPHost}:#{arg}"
@@ -419,7 +425,8 @@ module Puma
419
425
  end
420
426
 
421
427
  Signal.trap "SIGTERM" do
422
- graceful_stop server
428
+ log " - Gracefully stopping, waiting for requests to finish"
429
+ server.stop false
423
430
  end
424
431
 
425
432
  log "Use Ctrl-C to stop"
@@ -434,7 +441,7 @@ module Puma
434
441
 
435
442
  if @restart
436
443
  log "* Restarting..."
437
- @status.stop true
444
+ @status.stop true if @status
438
445
  restart!
439
446
  end
440
447
  end
data/lib/puma/const.rb CHANGED
@@ -25,7 +25,7 @@ module Puma
25
25
  # too taxing on performance.
26
26
  module Const
27
27
 
28
- PUMA_VERSION = VERSION = "1.2.2".freeze
28
+ PUMA_VERSION = VERSION = "1.3.0".freeze
29
29
 
30
30
  # The default number of seconds for another request within a persistent
31
31
  # session.
data/lib/puma/null_io.rb CHANGED
@@ -4,7 +4,6 @@ module Puma
4
4
  # Used as the value for rack.input when the request has no body.
5
5
  #
6
6
  class NullIO
7
-
8
7
  # Always returns nil
9
8
  #
10
9
  def gets
@@ -16,10 +15,10 @@ module Puma
16
15
  def each
17
16
  end
18
17
 
19
- # Always returns nil
18
+ # Mimics IO#read with no data
20
19
  #
21
- def read(count)
22
- nil
20
+ def read(count=nil,buffer=nil)
21
+ (count && count > 0) ? nil : ""
23
22
  end
24
23
 
25
24
  # Does nothing
data/puma.gemspec CHANGED
@@ -2,25 +2,25 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "puma"
5
- s.version = "1.2.2"
5
+ s.version = "1.3.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Evan Phoenix"]
9
- s.date = "2012-04-28"
9
+ s.date = "2012-05-08"
10
10
  s.description = "Puma is a simple, fast, and highly concurrent HTTP 1.1 server for Ruby web applications. It can be used with any application that supports Rack, and is considered the replacement for Webrick and Mongrel. It was designed to be the go-to server for [Rubinius](http://rubini.us), but also works well with JRuby and MRI. Puma is intended for use in both development and production environments.\n\nUnder the hood, Puma processes requests using a C-optimized Ragel extension (inherited from Mongrel) that provides fast, accurate HTTP 1.1 protocol parsing in a portable way. Puma then serves the request in a thread from an internal thread pool (which you can control). This allows Puma to provide real concurrency for your web application!\n\nWith Rubinius 2.0, Puma will utilize all cores on your CPU with real threads, meaning you won't have to spawn multiple processes to increase throughput. You can expect to see a similar benefit from JRuby.\n\nOn MRI, there is a Global Interpreter Lock (GIL) that ensures only one thread can be run at a time. But if you're doing a lot of blocking IO (such as HTTP calls to external APIs like Twitter), Puma still improves MRI's throughput by allowing blocking IO to be run concurrently (EventMachine-based servers such as Thin turn off this ability, requiring you to use special libraries). Your mileage may vary. In order to get the best throughput, it is highly recommended that you use a Ruby implementation with real threads like [Rubinius](http://rubini.us) or [JRuby](http://jruby.org)."
11
11
  s.email = ["evan@phx.io"]
12
12
  s.executables = ["puma", "pumactl"]
13
13
  s.extensions = ["ext/puma_http11/extconf.rb"]
14
14
  s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
15
- s.files = ["COPYING", "Gemfile", "History.txt", "LICENSE", "Manifest.txt", "README.md", "Rakefile", "TODO", "bin/puma", "bin/pumactl", "examples/CA/cacert.pem", "examples/CA/newcerts/cert_1.pem", "examples/CA/newcerts/cert_2.pem", "examples/CA/private/cakeypair.pem", "examples/CA/serial", "examples/config.rb", "examples/puma/cert_puma.pem", "examples/puma/csr_puma.pem", "examples/puma/puma_keypair.pem", "examples/qc_config.rb", "ext/puma_http11/PumaHttp11Service.java", "ext/puma_http11/ext_help.h", "ext/puma_http11/extconf.rb", "ext/puma_http11/http11_parser.c", "ext/puma_http11/http11_parser.h", "ext/puma_http11/http11_parser.java.rl", "ext/puma_http11/http11_parser.rl", "ext/puma_http11/http11_parser_common.rl", "ext/puma_http11/org/jruby/puma/Http11.java", "ext/puma_http11/org/jruby/puma/Http11Parser.java", "ext/puma_http11/puma_http11.c", "lib/puma.rb", "lib/puma/app/status.rb", "lib/puma/cli.rb", "lib/puma/compat.rb", "lib/puma/configuration.rb", "lib/puma/const.rb", "lib/puma/control_cli.rb", "lib/puma/events.rb", "lib/puma/jruby_restart.rb", "lib/puma/null_io.rb", "lib/puma/rack_patch.rb", "lib/puma/server.rb", "lib/puma/thread_pool.rb", "lib/rack/handler/puma.rb", "puma.gemspec", "test/ab_rs.rb", "test/config/app.rb", "test/hello.ru", "test/lobster.ru", "test/mime.yaml", "test/slow.ru", "test/test_app_status.rb", "test/test_cli.rb", "test/test_config.rb", "test/test_http10.rb", "test/test_http11.rb", "test/test_integration.rb", "test/test_persistent.rb", "test/test_puma_server.rb", "test/test_rack_handler.rb", "test/test_rack_server.rb", "test/test_thread_pool.rb", "test/test_unix_socket.rb", "test/test_ws.rb", "test/testhelp.rb", "tools/trickletest.rb"]
16
- s.homepage = "[![Build Status](https://secure.travis-ci.org/puma/puma.png)](http://travis-ci.org/puma/puma) [![Dependency Status](https://gemnasium.com/puma/puma.png)](https://gemnasium.com/puma/puma)"
15
+ s.files = ["COPYING", "Gemfile", "History.txt", "LICENSE", "Manifest.txt", "README.md", "Rakefile", "TODO", "bin/puma", "bin/pumactl", "examples/CA/cacert.pem", "examples/CA/newcerts/cert_1.pem", "examples/CA/newcerts/cert_2.pem", "examples/CA/private/cakeypair.pem", "examples/CA/serial", "examples/config.rb", "examples/puma/cert_puma.pem", "examples/puma/csr_puma.pem", "examples/puma/puma_keypair.pem", "examples/qc_config.rb", "ext/puma_http11/PumaHttp11Service.java", "ext/puma_http11/ext_help.h", "ext/puma_http11/extconf.rb", "ext/puma_http11/http11_parser.c", "ext/puma_http11/http11_parser.h", "ext/puma_http11/http11_parser.java.rl", "ext/puma_http11/http11_parser.rl", "ext/puma_http11/http11_parser_common.rl", "ext/puma_http11/org/jruby/puma/Http11.java", "ext/puma_http11/org/jruby/puma/Http11Parser.java", "ext/puma_http11/puma_http11.c", "lib/puma.rb", "lib/puma/app/status.rb", "lib/puma/cli.rb", "lib/puma/compat.rb", "lib/puma/configuration.rb", "lib/puma/const.rb", "lib/puma/control_cli.rb", "lib/puma/events.rb", "lib/puma/jruby_restart.rb", "lib/puma/null_io.rb", "lib/puma/rack_patch.rb", "lib/puma/server.rb", "lib/puma/thread_pool.rb", "lib/rack/handler/puma.rb", "puma.gemspec", "test/ab_rs.rb", "test/config/app.rb", "test/hello.ru", "test/lobster.ru", "test/mime.yaml", "test/slow.ru", "test/test_app_status.rb", "test/test_cli.rb", "test/test_config.rb", "test/test_http10.rb", "test/test_http11.rb", "test/test_integration.rb", "test/test_persistent.rb", "test/test_puma_server.rb", "test/test_rack_handler.rb", "test/test_rack_server.rb", "test/test_thread_pool.rb", "test/test_unix_socket.rb", "test/test_ws.rb", "test/testhelp.rb", "tools/trickletest.rb", "test/test_null_io.rb"]
16
+ s.homepage = "http://puma.io"
17
17
  s.rdoc_options = ["--main", "README.md"]
18
18
  s.require_paths = ["lib"]
19
19
  s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
20
20
  s.rubyforge_project = "puma"
21
- s.rubygems_version = "1.8.18"
21
+ s.rubygems_version = "1.8.22"
22
22
  s.summary = "Puma is a simple, fast, and highly concurrent HTTP 1.1 server for Ruby web applications"
23
- s.test_files = ["test/test_app_status.rb", "test/test_cli.rb", "test/test_config.rb", "test/test_http10.rb", "test/test_http11.rb", "test/test_integration.rb", "test/test_persistent.rb", "test/test_puma_server.rb", "test/test_rack_handler.rb", "test/test_rack_server.rb", "test/test_thread_pool.rb", "test/test_unix_socket.rb", "test/test_ws.rb"]
23
+ s.test_files = ["test/test_app_status.rb", "test/test_cli.rb", "test/test_config.rb", "test/test_http10.rb", "test/test_http11.rb", "test/test_integration.rb", "test/test_null_io.rb", "test/test_persistent.rb", "test/test_puma_server.rb", "test/test_rack_handler.rb", "test/test_rack_server.rb", "test/test_thread_pool.rb", "test/test_unix_socket.rb", "test/test_ws.rb"]
24
24
 
25
25
  if s.respond_to? :specification_version then
26
26
  s.specification_version = 3
@@ -29,17 +29,17 @@ Gem::Specification.new do |s|
29
29
  s.add_runtime_dependency(%q<rack>, ["~> 1.2"])
30
30
  s.add_development_dependency(%q<rake-compiler>, ["~> 0.8.0"])
31
31
  s.add_development_dependency(%q<rdoc>, ["~> 3.10"])
32
- s.add_development_dependency(%q<hoe>, ["~> 2.14"])
32
+ s.add_development_dependency(%q<hoe>, ["~> 2.16"])
33
33
  else
34
34
  s.add_dependency(%q<rack>, ["~> 1.2"])
35
35
  s.add_dependency(%q<rake-compiler>, ["~> 0.8.0"])
36
36
  s.add_dependency(%q<rdoc>, ["~> 3.10"])
37
- s.add_dependency(%q<hoe>, ["~> 2.14"])
37
+ s.add_dependency(%q<hoe>, ["~> 2.16"])
38
38
  end
39
39
  else
40
40
  s.add_dependency(%q<rack>, ["~> 1.2"])
41
41
  s.add_dependency(%q<rake-compiler>, ["~> 0.8.0"])
42
42
  s.add_dependency(%q<rdoc>, ["~> 3.10"])
43
- s.add_dependency(%q<hoe>, ["~> 2.14"])
43
+ s.add_dependency(%q<hoe>, ["~> 2.16"])
44
44
  end
45
45
  end
@@ -1,4 +1,5 @@
1
1
  require 'test/unit'
2
+ require 'rack'
2
3
  require 'puma/app/status'
3
4
 
4
5
  class TestAppStatus < Test::Unit::TestCase
@@ -27,6 +28,12 @@ class TestAppStatus < Test::Unit::TestCase
27
28
  @app.auth_token = nil
28
29
  end
29
30
 
31
+ def lint(env)
32
+ app = Rack::Lint.new @app
33
+ mock_env = Rack::MockRequest.env_for env['PATH_INFO']
34
+ app.call mock_env
35
+ end
36
+
30
37
  def test_bad_token
31
38
  @app.auth_token = "abcdef"
32
39
 
@@ -35,6 +42,7 @@ class TestAppStatus < Test::Unit::TestCase
35
42
  status, _, _ = @app.call env
36
43
 
37
44
  assert_equal 403, status
45
+ lint(env)
38
46
  end
39
47
 
40
48
  def test_good_token
@@ -48,6 +56,7 @@ class TestAppStatus < Test::Unit::TestCase
48
56
  status, _, _ = @app.call env
49
57
 
50
58
  assert_equal 404, status
59
+ lint(env)
51
60
  end
52
61
 
53
62
  def test_unsupported
@@ -56,6 +65,7 @@ class TestAppStatus < Test::Unit::TestCase
56
65
  status, _, _ = @app.call env
57
66
 
58
67
  assert_equal 404, status
68
+ lint(env)
59
69
  end
60
70
 
61
71
  def test_stop
@@ -66,6 +76,7 @@ class TestAppStatus < Test::Unit::TestCase
66
76
  assert_equal :stop, @server.status
67
77
  assert_equal 200, status
68
78
  assert_equal ['{ "status": "ok" }'], body
79
+ lint(env)
69
80
  end
70
81
 
71
82
  def test_halt
@@ -76,6 +87,7 @@ class TestAppStatus < Test::Unit::TestCase
76
87
  assert_equal :halt, @server.status
77
88
  assert_equal 200, status
78
89
  assert_equal ['{ "status": "ok" }'], body
90
+ lint(env)
79
91
  end
80
92
 
81
93
  def test_stats
@@ -88,6 +100,7 @@ class TestAppStatus < Test::Unit::TestCase
88
100
 
89
101
  assert_equal 200, status
90
102
  assert_equal ['{ "backlog": 1, "running": 9 }'], body
103
+ lint(env)
91
104
  end
92
105
 
93
106
  end
data/test/test_cli.rb CHANGED
@@ -109,4 +109,20 @@ class TestCLI < Test::Unit::TestCase
109
109
  assert_equal Process.pid, data["pid"]
110
110
  assert_equal url, data["config"].options[:control_url]
111
111
  end
112
+
113
+ def test_load_path
114
+ cli = Puma::CLI.new ["--include", 'foo/bar']
115
+ cli.parse_options
116
+
117
+ assert_equal 'foo/bar', $LOAD_PATH[0]
118
+ $LOAD_PATH.shift
119
+
120
+ cli = Puma::CLI.new ["--include", 'foo/bar:baz/qux']
121
+ cli.parse_options
122
+
123
+ assert_equal 'foo/bar', $LOAD_PATH[0]
124
+ $LOAD_PATH.shift
125
+ assert_equal 'baz/qux', $LOAD_PATH[0]
126
+ $LOAD_PATH.shift
127
+ end
112
128
  end
@@ -0,0 +1,31 @@
1
+ require 'puma/null_io'
2
+ require 'test/unit'
3
+
4
+ class TestNullIO < Test::Unit::TestCase
5
+ attr_accessor :nio
6
+ def setup
7
+ self.nio = Puma::NullIO.new
8
+ end
9
+
10
+ def test_read_with_no_arguments
11
+ assert_equal "", nio.read
12
+ end
13
+
14
+ def test_read_with_nil_length
15
+ assert_equal "", nio.read(nil)
16
+ end
17
+
18
+ def test_read_with_zero_length
19
+ assert_equal "", nio.read(0)
20
+ end
21
+
22
+ def test_read_with_positive_integer_length
23
+ assert_nil nio.read(1)
24
+ end
25
+
26
+ def test_read_with_length_and_buffer
27
+ buf = ""
28
+ assert_nil nio.read(1,buf)
29
+ assert_equal "", buf
30
+ end
31
+ end
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 2
9
- - 2
10
- version: 1.2.2
8
+ - 3
9
+ - 0
10
+ version: 1.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Evan Phoenix
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-28 00:00:00 Z
18
+ date: 2012-05-08 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rack
@@ -33,34 +33,34 @@ dependencies:
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- name: rdoc
36
+ name: rake-compiler
37
37
  prerelease: false
38
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- hash: 19
43
+ hash: 63
44
44
  segments:
45
- - 3
46
- - 10
47
- version: "3.10"
45
+ - 0
46
+ - 8
47
+ - 0
48
+ version: 0.8.0
48
49
  type: :development
49
50
  version_requirements: *id002
50
51
  - !ruby/object:Gem::Dependency
51
- name: rake-compiler
52
+ name: rdoc
52
53
  prerelease: false
53
54
  requirement: &id003 !ruby/object:Gem::Requirement
54
55
  none: false
55
56
  requirements:
56
57
  - - ~>
57
58
  - !ruby/object:Gem::Version
58
- hash: 63
59
+ hash: 19
59
60
  segments:
60
- - 0
61
- - 8
62
- - 0
63
- version: 0.8.0
61
+ - 3
62
+ - 10
63
+ version: "3.10"
64
64
  type: :development
65
65
  version_requirements: *id003
66
66
  - !ruby/object:Gem::Dependency
@@ -71,11 +71,11 @@ dependencies:
71
71
  requirements:
72
72
  - - ~>
73
73
  - !ruby/object:Gem::Version
74
- hash: 7
74
+ hash: 35
75
75
  segments:
76
- - 3
77
- - 0
78
- version: "3.0"
76
+ - 2
77
+ - 16
78
+ version: "2.16"
79
79
  type: :development
80
80
  version_requirements: *id004
81
81
  description: |-
@@ -97,6 +97,7 @@ extra_rdoc_files:
97
97
  - History.txt
98
98
  - Manifest.txt
99
99
  files:
100
+ - .travis.yml
100
101
  - COPYING
101
102
  - Gemfile
102
103
  - History.txt
@@ -155,6 +156,7 @@ files:
155
156
  - test/test_http10.rb
156
157
  - test/test_http11.rb
157
158
  - test/test_integration.rb
159
+ - test/test_null_io.rb
158
160
  - test/test_persistent.rb
159
161
  - test/test_puma_server.rb
160
162
  - test/test_rack_handler.rb
@@ -196,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
198
  requirements: []
197
199
 
198
200
  rubyforge_project: puma
199
- rubygems_version: 1.8.18
201
+ rubygems_version: 1.8.22
200
202
  signing_key:
201
203
  specification_version: 3
202
204
  summary: Puma is a simple, fast, and highly concurrent HTTP 1.1 server for Ruby web applications
@@ -207,6 +209,7 @@ test_files:
207
209
  - test/test_http10.rb
208
210
  - test/test_http11.rb
209
211
  - test/test_integration.rb
212
+ - test/test_null_io.rb
210
213
  - test/test_persistent.rb
211
214
  - test/test_puma_server.rb
212
215
  - test/test_rack_handler.rb