puma 3.12.6 → 4.3.12

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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +155 -3
  3. data/LICENSE +0 -0
  4. data/README.md +76 -48
  5. data/bin/puma-wild +0 -0
  6. data/docs/architecture.md +1 -0
  7. data/docs/deployment.md +24 -4
  8. data/docs/images/puma-connection-flow-no-reactor.png +0 -0
  9. data/docs/images/puma-connection-flow.png +0 -0
  10. data/docs/images/puma-general-arch.png +0 -0
  11. data/docs/nginx.md +0 -0
  12. data/docs/plugins.md +20 -10
  13. data/docs/restart.md +4 -2
  14. data/docs/signals.md +0 -0
  15. data/docs/systemd.md +27 -9
  16. data/docs/tcp_mode.md +96 -0
  17. data/ext/puma_http11/PumaHttp11Service.java +2 -0
  18. data/ext/puma_http11/ext_help.h +0 -0
  19. data/ext/puma_http11/extconf.rb +21 -0
  20. data/ext/puma_http11/http11_parser.c +58 -70
  21. data/ext/puma_http11/http11_parser.h +0 -0
  22. data/ext/puma_http11/http11_parser.java.rl +21 -37
  23. data/ext/puma_http11/http11_parser.rl +0 -0
  24. data/ext/puma_http11/http11_parser_common.rl +4 -4
  25. data/ext/puma_http11/io_buffer.c +0 -0
  26. data/ext/puma_http11/mini_ssl.c +138 -33
  27. data/ext/puma_http11/org/jruby/puma/Http11.java +106 -114
  28. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +86 -99
  29. data/ext/puma_http11/org/jruby/puma/IOBuffer.java +72 -0
  30. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +15 -4
  31. data/ext/puma_http11/puma_http11.c +3 -0
  32. data/lib/puma/accept_nonblock.rb +7 -1
  33. data/lib/puma/app/status.rb +37 -29
  34. data/lib/puma/binder.rb +38 -60
  35. data/lib/puma/cli.rb +4 -0
  36. data/lib/puma/client.rb +285 -208
  37. data/lib/puma/cluster.rb +53 -30
  38. data/lib/puma/commonlogger.rb +0 -0
  39. data/lib/puma/configuration.rb +4 -3
  40. data/lib/puma/const.rb +26 -20
  41. data/lib/puma/control_cli.rb +30 -5
  42. data/lib/puma/detect.rb +0 -0
  43. data/lib/puma/dsl.rb +299 -75
  44. data/lib/puma/events.rb +4 -1
  45. data/lib/puma/io_buffer.rb +1 -6
  46. data/lib/puma/jruby_restart.rb +0 -0
  47. data/lib/puma/launcher.rb +95 -53
  48. data/lib/puma/minissl/context_builder.rb +76 -0
  49. data/lib/puma/minissl.rb +35 -17
  50. data/lib/puma/null_io.rb +0 -0
  51. data/lib/puma/plugin/tmp_restart.rb +2 -0
  52. data/lib/puma/plugin.rb +5 -2
  53. data/lib/puma/rack/builder.rb +2 -0
  54. data/lib/puma/rack/urlmap.rb +2 -0
  55. data/lib/puma/rack_default.rb +2 -0
  56. data/lib/puma/reactor.rb +110 -57
  57. data/lib/puma/runner.rb +11 -3
  58. data/lib/puma/server.rb +89 -61
  59. data/lib/puma/single.rb +3 -3
  60. data/lib/puma/state_file.rb +0 -0
  61. data/lib/puma/tcp_logger.rb +0 -0
  62. data/lib/puma/thread_pool.rb +15 -33
  63. data/lib/puma/util.rb +1 -6
  64. data/lib/puma.rb +8 -0
  65. data/lib/rack/handler/puma.rb +3 -3
  66. data/tools/docker/Dockerfile +16 -0
  67. data/tools/jungle/README.md +0 -0
  68. data/tools/jungle/init.d/README.md +0 -0
  69. data/tools/jungle/init.d/puma +6 -6
  70. data/tools/jungle/rc.d/README.md +0 -0
  71. data/tools/jungle/rc.d/puma.conf +0 -0
  72. data/tools/jungle/upstart/README.md +0 -0
  73. data/tools/jungle/upstart/puma-manager.conf +0 -0
  74. data/tools/jungle/upstart/puma.conf +0 -0
  75. data/tools/trickletest.rb +0 -1
  76. metadata +26 -13
  77. data/lib/puma/compat.rb +0 -14
  78. data/lib/puma/convenient.rb +0 -25
  79. data/lib/puma/daemon_ext.rb +0 -33
  80. data/lib/puma/delegation.rb +0 -13
  81. data/lib/puma/java_io_buffer.rb +0 -47
  82. data/lib/puma/rack/backports/uri/common_193.rb +0 -33
data/lib/puma/binder.rb CHANGED
@@ -5,6 +5,7 @@ require 'socket'
5
5
 
6
6
  require 'puma/const'
7
7
  require 'puma/util'
8
+ require 'puma/minissl/context_builder'
8
9
 
9
10
  module Puma
10
11
  class Binder
@@ -42,7 +43,7 @@ module Puma
42
43
  @ios = []
43
44
  end
44
45
 
45
- attr_reader :listeners, :ios
46
+ attr_reader :ios
46
47
 
47
48
  def env(sock)
48
49
  @envs.fetch(sock, @proto_env)
@@ -50,7 +51,6 @@ module Puma
50
51
 
51
52
  def close
52
53
  @ios.each { |i| i.close }
53
- @unix_paths.each { |i| File.unlink i }
54
54
  end
55
55
 
56
56
  def import_from_env
@@ -104,7 +104,17 @@ module Puma
104
104
  bak = params.fetch('backlog', 1024).to_i
105
105
 
106
106
  io = add_tcp_listener uri.host, uri.port, opt, bak
107
- logger.log "* Listening on #{str}"
107
+
108
+ @ios.each do |i|
109
+ next unless TCPServer === i
110
+ addr = if i.local_address.ipv6?
111
+ "[#{i.local_address.ip_unpack[0]}]:#{i.local_address.ip_unpack[1]}"
112
+ else
113
+ i.local_address.ip_unpack.join(':')
114
+ end
115
+
116
+ logger.log "* Listening on tcp://#{addr}"
117
+ end
108
118
  end
109
119
 
110
120
  @listeners << [str, io] if io
@@ -145,61 +155,7 @@ module Puma
145
155
  @listeners << [str, io]
146
156
  when "ssl"
147
157
  params = Util.parse_query uri.query
148
- require 'puma/minissl'
149
-
150
- MiniSSL.check
151
-
152
- ctx = MiniSSL::Context.new
153
-
154
- if defined?(JRUBY_VERSION)
155
- unless params['keystore']
156
- @events.error "Please specify the Java keystore via 'keystore='"
157
- end
158
-
159
- ctx.keystore = params['keystore']
160
-
161
- unless params['keystore-pass']
162
- @events.error "Please specify the Java keystore password via 'keystore-pass='"
163
- end
164
-
165
- ctx.keystore_pass = params['keystore-pass']
166
- ctx.ssl_cipher_list = params['ssl_cipher_list'] if params['ssl_cipher_list']
167
- else
168
- unless params['key']
169
- @events.error "Please specify the SSL key via 'key='"
170
- end
171
-
172
- ctx.key = params['key']
173
-
174
- unless params['cert']
175
- @events.error "Please specify the SSL cert via 'cert='"
176
- end
177
-
178
- ctx.cert = params['cert']
179
-
180
- if ['peer', 'force_peer'].include?(params['verify_mode'])
181
- unless params['ca']
182
- @events.error "Please specify the SSL ca via 'ca='"
183
- end
184
- end
185
-
186
- ctx.ca = params['ca'] if params['ca']
187
- ctx.ssl_cipher_filter = params['ssl_cipher_filter'] if params['ssl_cipher_filter']
188
- end
189
-
190
- if params['verify_mode']
191
- ctx.verify_mode = case params['verify_mode']
192
- when "peer"
193
- MiniSSL::VERIFY_PEER
194
- when "force_peer"
195
- MiniSSL::VERIFY_PEER | MiniSSL::VERIFY_FAIL_IF_NO_PEER_CERT
196
- when "none"
197
- MiniSSL::VERIFY_NONE
198
- else
199
- @events.error "Please specify a valid verify_mode="
200
- MiniSSL::VERIFY_NONE
201
- end
202
- end
158
+ ctx = MiniSSL::ContextBuilder.new(params, @events).context
203
159
 
204
160
  if fd = @inherited_fds.delete(str)
205
161
  logger.log "* Inherited #{str}"
@@ -349,7 +305,7 @@ module Puma
349
305
  # Tell the server to listen on +path+ as a UNIX domain socket.
350
306
  #
351
307
  def add_unix_listener(path, umask=nil, mode=nil, backlog=1024)
352
- @unix_paths << path
308
+ @unix_paths << path unless File.exist? path
353
309
 
354
310
  # Let anyone connect by default
355
311
  umask ||= 0
@@ -387,7 +343,7 @@ module Puma
387
343
  end
388
344
 
389
345
  def inherit_unix_listener(path, fd)
390
- @unix_paths << path
346
+ @unix_paths << path unless File.exist? path
391
347
 
392
348
  if fd.kind_of? TCPServer
393
349
  s = fd
@@ -403,5 +359,27 @@ module Puma
403
359
  s
404
360
  end
405
361
 
362
+ def close_listeners
363
+ @listeners.each do |l, io|
364
+ io.close
365
+ uri = URI.parse(l)
366
+ next unless uri.scheme == 'unix'
367
+ unix_path = "#{uri.host}#{uri.path}"
368
+ File.unlink unix_path if @unix_paths.include? unix_path
369
+ end
370
+ end
371
+
372
+ def close_unix_paths
373
+ @unix_paths.each { |up| File.unlink(up) if File.exist? up }
374
+ end
375
+
376
+ def redirects_for_restart
377
+ redirects = {:close_others => true}
378
+ @listeners.each_with_index do |(l, io), i|
379
+ ENV["PUMA_INHERIT_#{i}"] = "#{io.to_i}:#{l}"
380
+ redirects[io.to_i] = io.to_i
381
+ end
382
+ redirects
383
+ end
406
384
  end
407
385
  end
data/lib/puma/cli.rb CHANGED
@@ -161,6 +161,10 @@ module Puma
161
161
  user_config.prune_bundler
162
162
  end
163
163
 
164
+ o.on "--extra-runtime-dependencies GEM1,GEM2", "Defines any extra needed gems when using --prune-bundler" do |arg|
165
+ user_config.extra_runtime_dependencies arg.split(',')
166
+ end
167
+
164
168
  o.on "-q", "--quiet", "Do not log requests internally (default true)" do
165
169
  user_config.quiet
166
170
  end