puma 2.7.0 → 3.1.1

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.

Files changed (79) hide show
  1. checksums.yaml +5 -13
  2. data/DEPLOYMENT.md +91 -0
  3. data/Gemfile +3 -2
  4. data/History.txt +624 -1
  5. data/Manifest.txt +15 -3
  6. data/README.md +129 -14
  7. data/Rakefile +3 -3
  8. data/bin/puma-wild +31 -0
  9. data/bin/pumactl +1 -1
  10. data/docs/nginx.md +1 -1
  11. data/docs/signals.md +43 -0
  12. data/ext/puma_http11/extconf.rb +7 -2
  13. data/ext/puma_http11/http11_parser.java.rl +5 -5
  14. data/ext/puma_http11/io_buffer.c +1 -1
  15. data/ext/puma_http11/mini_ssl.c +233 -18
  16. data/ext/puma_http11/org/jruby/puma/Http11.java +12 -3
  17. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +39 -39
  18. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +245 -195
  19. data/ext/puma_http11/puma_http11.c +12 -4
  20. data/lib/puma.rb +1 -0
  21. data/lib/puma/app/status.rb +7 -0
  22. data/lib/puma/binder.rb +108 -39
  23. data/lib/puma/capistrano.rb +23 -6
  24. data/lib/puma/cli.rb +141 -446
  25. data/lib/puma/client.rb +48 -1
  26. data/lib/puma/cluster.rb +207 -58
  27. data/lib/puma/commonlogger.rb +107 -0
  28. data/lib/puma/configuration.rb +262 -235
  29. data/lib/puma/const.rb +97 -14
  30. data/lib/puma/control_cli.rb +85 -77
  31. data/lib/puma/convenient.rb +23 -0
  32. data/lib/puma/daemon_ext.rb +11 -4
  33. data/lib/puma/detect.rb +8 -1
  34. data/lib/puma/dsl.rb +456 -0
  35. data/lib/puma/events.rb +35 -18
  36. data/lib/puma/jruby_restart.rb +1 -1
  37. data/lib/puma/launcher.rb +399 -0
  38. data/lib/puma/minissl.rb +49 -20
  39. data/lib/puma/null_io.rb +15 -0
  40. data/lib/puma/plugin.rb +104 -0
  41. data/lib/puma/plugin/tmp_restart.rb +35 -0
  42. data/lib/puma/rack/backports/uri/common_18.rb +56 -0
  43. data/lib/puma/rack/backports/uri/common_192.rb +52 -0
  44. data/lib/puma/rack/backports/uri/common_193.rb +29 -0
  45. data/lib/puma/rack/builder.rb +295 -0
  46. data/lib/puma/rack/urlmap.rb +90 -0
  47. data/lib/puma/reactor.rb +14 -1
  48. data/lib/puma/runner.rb +35 -17
  49. data/lib/puma/server.rb +161 -58
  50. data/lib/puma/single.rb +15 -10
  51. data/lib/puma/state_file.rb +29 -0
  52. data/lib/puma/thread_pool.rb +88 -13
  53. data/lib/puma/util.rb +123 -0
  54. data/lib/rack/handler/puma.rb +35 -29
  55. data/puma.gemspec +2 -4
  56. data/tools/jungle/init.d/README.md +2 -2
  57. data/tools/jungle/init.d/puma +69 -7
  58. data/tools/jungle/upstart/puma.conf +8 -2
  59. metadata +51 -71
  60. data/COPYING +0 -55
  61. data/TODO +0 -5
  62. data/lib/puma/rack_patch.rb +0 -45
  63. data/test/test_app_status.rb +0 -92
  64. data/test/test_cli.rb +0 -173
  65. data/test/test_config.rb +0 -16
  66. data/test/test_http10.rb +0 -27
  67. data/test/test_http11.rb +0 -145
  68. data/test/test_integration.rb +0 -165
  69. data/test/test_iobuffer.rb +0 -38
  70. data/test/test_minissl.rb +0 -25
  71. data/test/test_null_io.rb +0 -31
  72. data/test/test_persistent.rb +0 -238
  73. data/test/test_puma_server.rb +0 -292
  74. data/test/test_rack_handler.rb +0 -10
  75. data/test/test_rack_server.rb +0 -141
  76. data/test/test_tcp_rack.rb +0 -42
  77. data/test/test_thread_pool.rb +0 -156
  78. data/test/test_unix_socket.rb +0 -39
  79. data/test/test_ws.rb +0 -89
@@ -1,156 +0,0 @@
1
- require 'test/unit'
2
-
3
- require 'puma/thread_pool'
4
-
5
- class TestThreadPool < Test::Unit::TestCase
6
-
7
- def teardown
8
- @pool.shutdown if @pool
9
- end
10
-
11
- def new_pool(min, max, &block)
12
- block = proc { } unless block
13
- @pool = Puma::ThreadPool.new(min, max, &block)
14
- end
15
-
16
- def pause
17
- sleep 0.2
18
- end
19
-
20
- def test_append_spawns
21
- saw = []
22
-
23
- pool = new_pool(0, 1) do |work|
24
- saw << work
25
- end
26
-
27
- pool << 1
28
-
29
- pause
30
-
31
- assert_equal [1], saw
32
- assert_equal 1, pool.spawned
33
- end
34
-
35
- def test_converts_pool_sizes
36
- pool = new_pool('0', '1')
37
-
38
- assert_equal 0, pool.spawned
39
-
40
- pool << 1
41
-
42
- assert_equal 1, pool.spawned
43
- end
44
-
45
- def test_append_queues_on_max
46
- finish = false
47
- pool = new_pool(0, 1) { Thread.pass until finish }
48
-
49
- pool << 1
50
- pool << 2
51
- pool << 3
52
-
53
- pause
54
-
55
- assert_equal 2, pool.backlog
56
-
57
- finish = true
58
- end
59
-
60
- def test_trim
61
- pool = new_pool(0, 1)
62
-
63
- pool << 1
64
-
65
- pause
66
-
67
- assert_equal 1, pool.spawned
68
- pool.trim
69
-
70
- pause
71
- assert_equal 0, pool.spawned
72
- end
73
-
74
- def test_trim_leaves_min
75
- finish = false
76
- pool = new_pool(1, 2) { Thread.pass until finish }
77
-
78
- pool << 1
79
- pool << 2
80
-
81
- finish = true
82
-
83
- pause
84
-
85
- assert_equal 2, pool.spawned
86
- pool.trim
87
- pause
88
-
89
- assert_equal 1, pool.spawned
90
- pool.trim
91
- pause
92
-
93
- assert_equal 1, pool.spawned
94
-
95
- end
96
-
97
- def test_force_trim_doesnt_overtrim
98
- finish = false
99
- pool = new_pool(1, 2) { Thread.pass until finish }
100
-
101
- pool << 1
102
- pool << 2
103
-
104
- assert_equal 2, pool.spawned
105
- pool.trim true
106
- pool.trim true
107
-
108
- finish = true
109
-
110
- pause
111
-
112
- assert_equal 1, pool.spawned
113
- end
114
-
115
- def test_trim_is_ignored_if_no_waiting_threads
116
- finish = false
117
- pool = new_pool(1, 2) { Thread.pass until finish }
118
-
119
- pool << 1
120
- pool << 2
121
-
122
- assert_equal 2, pool.spawned
123
- pool.trim
124
- pool.trim
125
-
126
- assert_equal 0, pool.trim_requested
127
-
128
- finish = true
129
-
130
- pause
131
- end
132
-
133
- def test_autotrim
134
- finish = false
135
- pool = new_pool(1, 2) { Thread.pass until finish }
136
-
137
- pool << 1
138
- pool << 2
139
-
140
- assert_equal 2, pool.spawned
141
-
142
- finish = true
143
-
144
- pause
145
-
146
- assert_equal 2, pool.spawned
147
-
148
- pool.auto_trim! 1
149
-
150
- sleep 1
151
-
152
- pause
153
-
154
- assert_equal 1, pool.spawned
155
- end
156
- end
@@ -1,39 +0,0 @@
1
- require "rbconfig"
2
- require 'test/unit'
3
- require 'puma/server'
4
-
5
- require 'socket'
6
-
7
- # UNIX sockets are not recommended on JRuby
8
- # (or Windows)
9
- unless defined?(JRUBY_VERSION) || RbConfig::CONFIG["host_os"] =~ /mingw|mswin/
10
- class TestPumaUnixSocket < Test::Unit::TestCase
11
-
12
- App = lambda { |env| [200, {}, ["Works"]] }
13
-
14
- Path = "test/puma.sock"
15
-
16
- def setup
17
- @server = Puma::Server.new App
18
- @server.add_unix_listener Path
19
- @server.run
20
- end
21
-
22
- def teardown
23
- @server.stop(true)
24
- File.unlink Path if File.exists? Path
25
- end
26
-
27
- def test_server
28
- sock = UNIXSocket.new Path
29
-
30
- sock << "GET / HTTP/1.0\r\nHost: blah.com\r\n\r\n"
31
-
32
- expected = "HTTP/1.0 200 OK\r\nConnection: close\r\nContent-Length: 5\r\n\r\nWorks"
33
-
34
- assert_equal expected, sock.read(expected.size)
35
-
36
- sock.close
37
- end
38
- end
39
- end
data/test/test_ws.rb DELETED
@@ -1,89 +0,0 @@
1
- # Copyright (c) 2011 Evan Phoenix
2
- # Copyright (c) 2005 Zed A. Shaw
3
-
4
- require 'test/testhelp'
5
-
6
- include Puma
7
-
8
- class TestHandler
9
- attr_reader :ran_test
10
-
11
- def call(env)
12
- @ran_test = true
13
-
14
- [200, {"Content-Type" => "text/plain"}, ["hello!"]]
15
- end
16
- end
17
-
18
- class WebServerTest < Test::Unit::TestCase
19
-
20
- def setup
21
- @valid_request = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\n\r\n"
22
-
23
- @tester = TestHandler.new
24
-
25
- @server = Server.new @tester, Events.strings
26
- @server.add_tcp_listener "127.0.0.1", 9998
27
-
28
- @server.run
29
- end
30
-
31
- def teardown
32
- @server.stop(true)
33
- end
34
-
35
- def test_simple_server
36
- hit(['http://127.0.0.1:9998/test'])
37
- assert @tester.ran_test, "Handler didn't really run"
38
- end
39
-
40
-
41
- def do_test(string, chunk, close_after=nil, shutdown_delay=0)
42
- # Do not use instance variables here, because it needs to be thread safe
43
- socket = TCPSocket.new("127.0.0.1", 9998);
44
- request = StringIO.new(string)
45
- chunks_out = 0
46
-
47
- while data = request.read(chunk)
48
- chunks_out += socket.write(data)
49
- socket.flush
50
- sleep 0.2
51
- if close_after and chunks_out > close_after
52
- socket.close
53
- sleep 1
54
- end
55
- end
56
- sleep(shutdown_delay)
57
- socket.write(" ") # Some platforms only raise the exception on attempted write
58
- socket.flush
59
- end
60
-
61
- def test_trickle_attack
62
- do_test(@valid_request, 3)
63
- end
64
-
65
- def test_close_client
66
- assert_raises IOError do
67
- do_test(@valid_request, 10, 20)
68
- end
69
- end
70
-
71
- def test_bad_client
72
- do_test("GET /test HTTP/BAD", 3)
73
- end
74
-
75
- def test_header_is_too_long
76
- long = "GET /test HTTP/1.1\r\n" + ("X-Big: stuff\r\n" * 15000) + "\r\n"
77
- assert_raises Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNABORTED, Errno::EINVAL, IOError do
78
- do_test(long, long.length/2, 10)
79
- end
80
- end
81
-
82
- def test_file_streamed_request
83
- body = "a" * (Puma::Const::MAX_BODY * 2)
84
- long = "GET /test HTTP/1.1\r\nContent-length: #{body.length}\r\n\r\n" + body
85
- do_test(long, (Puma::Const::CHUNK_SIZE * 2) - 400)
86
- end
87
-
88
- end
89
-