jun-puma 1.0.1-java → 1.0.2-java

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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/lib/puma/puma_http11.jar +0 -0
  3. metadata +3 -81
  4. data/bin/puma-wild +0 -25
  5. data/docs/architecture.md +0 -74
  6. data/docs/compile_options.md +0 -55
  7. data/docs/deployment.md +0 -102
  8. data/docs/fork_worker.md +0 -31
  9. data/docs/images/puma-connection-flow-no-reactor.png +0 -0
  10. data/docs/images/puma-connection-flow.png +0 -0
  11. data/docs/images/puma-general-arch.png +0 -0
  12. data/docs/jungle/README.md +0 -9
  13. data/docs/jungle/rc.d/README.md +0 -74
  14. data/docs/jungle/rc.d/puma +0 -61
  15. data/docs/jungle/rc.d/puma.conf +0 -10
  16. data/docs/kubernetes.md +0 -78
  17. data/docs/nginx.md +0 -80
  18. data/docs/plugins.md +0 -38
  19. data/docs/rails_dev_mode.md +0 -28
  20. data/docs/restart.md +0 -64
  21. data/docs/signals.md +0 -98
  22. data/docs/stats.md +0 -142
  23. data/docs/systemd.md +0 -244
  24. data/docs/testing_benchmarks_local_files.md +0 -150
  25. data/docs/testing_test_rackup_ci_files.md +0 -36
  26. data/ext/puma_http11/PumaHttp11Service.java +0 -17
  27. data/ext/puma_http11/ext_help.h +0 -15
  28. data/ext/puma_http11/http11_parser.c +0 -1057
  29. data/ext/puma_http11/http11_parser.h +0 -65
  30. data/ext/puma_http11/http11_parser.java.rl +0 -145
  31. data/ext/puma_http11/http11_parser.rl +0 -149
  32. data/ext/puma_http11/http11_parser_common.rl +0 -54
  33. data/ext/puma_http11/mini_ssl.c +0 -832
  34. data/ext/puma_http11/no_ssl/PumaHttp11Service.java +0 -15
  35. data/ext/puma_http11/org/jruby/puma/Http11.java +0 -226
  36. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +0 -455
  37. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +0 -508
  38. data/ext/puma_http11/puma_http11.c +0 -492
  39. data/lib/puma/app/status.rb +0 -96
  40. data/lib/puma/binder.rb +0 -501
  41. data/lib/puma/cli.rb +0 -243
  42. data/lib/puma/client.rb +0 -632
  43. data/lib/puma/cluster/worker.rb +0 -182
  44. data/lib/puma/cluster/worker_handle.rb +0 -97
  45. data/lib/puma/cluster.rb +0 -562
  46. data/lib/puma/commonlogger.rb +0 -115
  47. data/lib/puma/configuration.rb +0 -391
  48. data/lib/puma/const.rb +0 -289
  49. data/lib/puma/control_cli.rb +0 -316
  50. data/lib/puma/detect.rb +0 -45
  51. data/lib/puma/dsl.rb +0 -1204
  52. data/lib/puma/error_logger.rb +0 -113
  53. data/lib/puma/events.rb +0 -57
  54. data/lib/puma/io_buffer.rb +0 -46
  55. data/lib/puma/jruby_restart.rb +0 -27
  56. data/lib/puma/json_serialization.rb +0 -96
  57. data/lib/puma/launcher/bundle_pruner.rb +0 -104
  58. data/lib/puma/launcher.rb +0 -484
  59. data/lib/puma/log_writer.rb +0 -147
  60. data/lib/puma/minissl/context_builder.rb +0 -95
  61. data/lib/puma/minissl.rb +0 -458
  62. data/lib/puma/null_io.rb +0 -61
  63. data/lib/puma/plugin/systemd.rb +0 -90
  64. data/lib/puma/plugin/tmp_restart.rb +0 -36
  65. data/lib/puma/plugin.rb +0 -111
  66. data/lib/puma/rack/builder.rb +0 -297
  67. data/lib/puma/rack/urlmap.rb +0 -93
  68. data/lib/puma/rack_default.rb +0 -24
  69. data/lib/puma/reactor.rb +0 -125
  70. data/lib/puma/request.rb +0 -671
  71. data/lib/puma/runner.rb +0 -213
  72. data/lib/puma/sd_notify.rb +0 -149
  73. data/lib/puma/server.rb +0 -664
  74. data/lib/puma/single.rb +0 -69
  75. data/lib/puma/state_file.rb +0 -68
  76. data/lib/puma/thread_pool.rb +0 -434
  77. data/lib/puma/util.rb +0 -141
  78. data/lib/puma.rb +0 -78
  79. data/lib/rack/handler/puma.rb +0 -141
  80. data/tools/Dockerfile +0 -16
  81. data/tools/trickletest.rb +0 -44
data/lib/puma/binder.rb DELETED
@@ -1,501 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'uri'
4
- require 'socket'
5
-
6
- require_relative 'const'
7
- require_relative 'util'
8
- require_relative 'configuration'
9
-
10
- module Puma
11
-
12
- if HAS_SSL
13
- require_relative 'minissl'
14
- require_relative 'minissl/context_builder'
15
- end
16
-
17
- class Binder
18
- include Puma::Const
19
-
20
- RACK_VERSION = [1,6].freeze
21
-
22
- def initialize(log_writer, conf = Configuration.new)
23
- @log_writer = log_writer
24
- @conf = conf
25
- @listeners = []
26
- @inherited_fds = {}
27
- @activated_sockets = {}
28
- @unix_paths = []
29
-
30
- @proto_env = {
31
- "rack.version".freeze => RACK_VERSION,
32
- "rack.errors".freeze => log_writer.stderr,
33
- "rack.multithread".freeze => conf.options[:max_threads] > 1,
34
- "rack.multiprocess".freeze => conf.options[:workers] >= 1,
35
- "rack.run_once".freeze => false,
36
- RACK_URL_SCHEME => conf.options[:rack_url_scheme],
37
- "SCRIPT_NAME".freeze => ENV['SCRIPT_NAME'] || "",
38
-
39
- # I'd like to set a default CONTENT_TYPE here but some things
40
- # depend on their not being a default set and inferring
41
- # it from the content. And so if i set it here, it won't
42
- # infer properly.
43
-
44
- "QUERY_STRING".freeze => "",
45
- SERVER_SOFTWARE => PUMA_SERVER_STRING,
46
- GATEWAY_INTERFACE => CGI_VER
47
- }
48
-
49
- @envs = {}
50
- @ios = []
51
- end
52
-
53
- attr_reader :ios
54
-
55
- # @version 5.0.0
56
- attr_reader :activated_sockets, :envs, :inherited_fds, :listeners, :proto_env, :unix_paths
57
-
58
- # @version 5.0.0
59
- attr_writer :ios, :listeners
60
-
61
- def env(sock)
62
- @envs.fetch(sock, @proto_env)
63
- end
64
-
65
- def close
66
- @ios.each { |i| i.close }
67
- end
68
-
69
- # @!attribute [r] connected_ports
70
- # @version 5.0.0
71
- def connected_ports
72
- t = ios.map { |io| io.addr[1] }; t.uniq!; t
73
- end
74
-
75
- # @version 5.0.0
76
- def create_inherited_fds(env_hash)
77
- env_hash.select {|k,v| k =~ /PUMA_INHERIT_\d+/}.each do |_k, v|
78
- fd, url = v.split(":", 2)
79
- @inherited_fds[url] = fd.to_i
80
- end.keys # pass keys back for removal
81
- end
82
-
83
- # systemd socket activation.
84
- # LISTEN_FDS = number of listening sockets. e.g. 2 means accept on 2 sockets w/descriptors 3 and 4.
85
- # LISTEN_PID = PID of the service process, aka us
86
- # @see https://www.freedesktop.org/software/systemd/man/systemd-socket-activate.html
87
- # @version 5.0.0
88
- #
89
- def create_activated_fds(env_hash)
90
- @log_writer.debug "ENV['LISTEN_FDS'] #{ENV['LISTEN_FDS'].inspect} env_hash['LISTEN_PID'] #{env_hash['LISTEN_PID'].inspect}"
91
- return [] unless env_hash['LISTEN_FDS'] && env_hash['LISTEN_PID'].to_i == $$
92
- env_hash['LISTEN_FDS'].to_i.times do |index|
93
- sock = TCPServer.for_fd(socket_activation_fd(index))
94
- key = begin # Try to parse as a path
95
- [:unix, Socket.unpack_sockaddr_un(sock.getsockname)]
96
- rescue ArgumentError # Try to parse as a port/ip
97
- port, addr = Socket.unpack_sockaddr_in(sock.getsockname)
98
- addr = "[#{addr}]" if addr&.include? ':'
99
- [:tcp, addr, port]
100
- end
101
- @activated_sockets[key] = sock
102
- @log_writer.debug "Registered #{key.join ':'} for activation from LISTEN_FDS"
103
- end
104
- ["LISTEN_FDS", "LISTEN_PID"] # Signal to remove these keys from ENV
105
- end
106
-
107
- # Synthesize binds from systemd socket activation
108
- #
109
- # When systemd socket activation is enabled, it can be tedious to keep the
110
- # binds in sync. This method can synthesize any binds based on the received
111
- # activated sockets. Any existing matching binds will be respected.
112
- #
113
- # When only_matching is true in, all binds that do not match an activated
114
- # socket is removed in place.
115
- #
116
- # It's a noop if no activated sockets were received.
117
- def synthesize_binds_from_activated_fs(binds, only_matching)
118
- return binds unless activated_sockets.any?
119
-
120
- activated_binds = []
121
-
122
- activated_sockets.keys.each do |proto, addr, port|
123
- if port
124
- tcp_url = "#{proto}://#{addr}:#{port}"
125
- ssl_url = "ssl://#{addr}:#{port}"
126
- ssl_url_prefix = "#{ssl_url}?"
127
-
128
- existing = binds.find { |bind| bind == tcp_url || bind == ssl_url || bind.start_with?(ssl_url_prefix) }
129
-
130
- activated_binds << (existing || tcp_url)
131
- else
132
- # TODO: can there be a SSL bind without a port?
133
- activated_binds << "#{proto}://#{addr}"
134
- end
135
- end
136
-
137
- if only_matching
138
- activated_binds
139
- else
140
- binds | activated_binds
141
- end
142
- end
143
-
144
- def parse(binds, log_writer = nil, log_msg = 'Listening')
145
- log_writer ||= @log_writer
146
- binds.each do |str|
147
- uri = URI.parse str
148
- case uri.scheme
149
- when "tcp"
150
- if fd = @inherited_fds.delete(str)
151
- io = inherit_tcp_listener uri.host, uri.port, fd
152
- log_writer.log "* Inherited #{str}"
153
- elsif sock = @activated_sockets.delete([ :tcp, uri.host, uri.port ])
154
- io = inherit_tcp_listener uri.host, uri.port, sock
155
- log_writer.log "* Activated #{str}"
156
- else
157
- ios_len = @ios.length
158
- params = Util.parse_query uri.query
159
-
160
- low_latency = params.key?('low_latency') && params['low_latency'] != 'false'
161
- backlog = params.fetch('backlog', 1024).to_i
162
-
163
- io = add_tcp_listener uri.host, uri.port, low_latency, backlog
164
-
165
- @ios[ios_len..-1].each do |i|
166
- addr = loc_addr_str i
167
- log_writer.log "* #{log_msg} on http://#{addr}"
168
- end
169
- end
170
-
171
- @listeners << [str, io] if io
172
- when "unix"
173
- path = "#{uri.host}#{uri.path}".gsub("%20", " ")
174
- abstract = false
175
- if str.start_with? 'unix://@'
176
- raise "OS does not support abstract UNIXSockets" unless Puma.abstract_unix_socket?
177
- abstract = true
178
- path = "@#{path}"
179
- end
180
-
181
- if fd = @inherited_fds.delete(str)
182
- @unix_paths << path unless abstract || File.exist?(path)
183
- io = inherit_unix_listener path, fd
184
- log_writer.log "* Inherited #{str}"
185
- elsif sock = @activated_sockets.delete([ :unix, path ]) ||
186
- @activated_sockets.delete([ :unix, File.realdirpath(path) ])
187
- @unix_paths << path unless abstract || File.exist?(path)
188
- io = inherit_unix_listener path, sock
189
- log_writer.log "* Activated #{str}"
190
- else
191
- umask = nil
192
- mode = nil
193
- backlog = 1024
194
-
195
- if uri.query
196
- params = Util.parse_query uri.query
197
- if u = params['umask']
198
- # Use Integer() to respect the 0 prefix as octal
199
- umask = Integer(u)
200
- end
201
-
202
- if u = params['mode']
203
- mode = Integer('0'+u)
204
- end
205
-
206
- if u = params['backlog']
207
- backlog = Integer(u)
208
- end
209
- end
210
-
211
- @unix_paths << path unless abstract || File.exist?(path)
212
- io = add_unix_listener path, umask, mode, backlog
213
- log_writer.log "* #{log_msg} on #{str}"
214
- end
215
-
216
- @listeners << [str, io]
217
- when "ssl"
218
- cert_key = %w[cert key]
219
-
220
- raise "Puma compiled without SSL support" unless HAS_SSL
221
-
222
- params = Util.parse_query uri.query
223
-
224
- # If key and certs are not defined and localhost gem is required.
225
- # localhost gem will be used for self signed
226
- # Load localhost authority if not loaded.
227
- # Ruby 3 `values_at` accepts an array, earlier do not
228
- if params.values_at(*cert_key).all? { |v| v.to_s.empty? }
229
- ctx = localhost_authority && localhost_authority_context
230
- end
231
-
232
- ctx ||=
233
- begin
234
- # Extract cert_pem and key_pem from options[:store] if present
235
- cert_key.each do |v|
236
- if params[v]&.start_with?('store:')
237
- index = Integer(params.delete(v).split('store:').last)
238
- params["#{v}_pem"] = @conf.options[:store][index]
239
- end
240
- end
241
- MiniSSL::ContextBuilder.new(params, @log_writer).context
242
- end
243
-
244
- if fd = @inherited_fds.delete(str)
245
- log_writer.log "* Inherited #{str}"
246
- io = inherit_ssl_listener fd, ctx
247
- elsif sock = @activated_sockets.delete([ :tcp, uri.host, uri.port ])
248
- io = inherit_ssl_listener sock, ctx
249
- log_writer.log "* Activated #{str}"
250
- else
251
- ios_len = @ios.length
252
- backlog = params.fetch('backlog', 1024).to_i
253
- low_latency = params['low_latency'] != 'false'
254
- io = add_ssl_listener uri.host, uri.port, ctx, low_latency, backlog
255
-
256
- @ios[ios_len..-1].each do |i|
257
- addr = loc_addr_str i
258
- log_writer.log "* #{log_msg} on ssl://#{addr}?#{uri.query}"
259
- end
260
- end
261
-
262
- @listeners << [str, io] if io
263
- else
264
- log_writer.error "Invalid URI: #{str}"
265
- end
266
- end
267
-
268
- # If we inherited fds but didn't use them (because of a
269
- # configuration change), then be sure to close them.
270
- @inherited_fds.each do |str, fd|
271
- log_writer.log "* Closing unused inherited connection: #{str}"
272
-
273
- begin
274
- IO.for_fd(fd).close
275
- rescue SystemCallError
276
- end
277
-
278
- # We have to unlink a unix socket path that's not being used
279
- uri = URI.parse str
280
- if uri.scheme == "unix"
281
- path = "#{uri.host}#{uri.path}"
282
- File.unlink path
283
- end
284
- end
285
-
286
- # Also close any unused activated sockets
287
- unless @activated_sockets.empty?
288
- fds = @ios.map(&:to_i)
289
- @activated_sockets.each do |key, sock|
290
- next if fds.include? sock.to_i
291
- log_writer.log "* Closing unused activated socket: #{key.first}://#{key[1..-1].join ':'}"
292
- begin
293
- sock.close
294
- rescue SystemCallError
295
- end
296
- # We have to unlink a unix socket path that's not being used
297
- File.unlink key[1] if key.first == :unix
298
- end
299
- end
300
- end
301
-
302
- def localhost_authority
303
- @localhost_authority ||= Localhost::Authority.fetch if defined?(Localhost::Authority) && !Puma::IS_JRUBY
304
- end
305
-
306
- def localhost_authority_context
307
- return unless localhost_authority
308
-
309
- key_path, crt_path = if [:key_path, :certificate_path].all? { |m| localhost_authority.respond_to?(m) }
310
- [localhost_authority.key_path, localhost_authority.certificate_path]
311
- else
312
- local_certificates_path = File.expand_path("~/.localhost")
313
- [File.join(local_certificates_path, "localhost.key"), File.join(local_certificates_path, "localhost.crt")]
314
- end
315
- MiniSSL::ContextBuilder.new({ "key" => key_path, "cert" => crt_path }, @log_writer).context
316
- end
317
-
318
- # Tell the server to listen on host +host+, port +port+.
319
- # If +optimize_for_latency+ is true (the default) then clients connecting
320
- # will be optimized for latency over throughput.
321
- #
322
- # +backlog+ indicates how many unaccepted connections the kernel should
323
- # allow to accumulate before returning connection refused.
324
- #
325
- def add_tcp_listener(host, port, optimize_for_latency=true, backlog=1024)
326
- if host == "localhost"
327
- loopback_addresses.each do |addr|
328
- add_tcp_listener addr, port, optimize_for_latency, backlog
329
- end
330
- return
331
- end
332
-
333
- host = host[1..-2] if host&.start_with? '['
334
- tcp_server = TCPServer.new(host, port)
335
-
336
- if optimize_for_latency
337
- tcp_server.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
338
- end
339
- tcp_server.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true)
340
- tcp_server.listen backlog
341
-
342
- @ios << tcp_server
343
- tcp_server
344
- end
345
-
346
- def inherit_tcp_listener(host, port, fd)
347
- s = fd.kind_of?(::TCPServer) ? fd : ::TCPServer.for_fd(fd)
348
-
349
- @ios << s
350
- s
351
- end
352
-
353
- def add_ssl_listener(host, port, ctx,
354
- optimize_for_latency=true, backlog=1024)
355
-
356
- raise "Puma compiled without SSL support" unless HAS_SSL
357
- # Puma will try to use local authority context if context is supplied nil
358
- ctx ||= localhost_authority_context
359
-
360
- if host == "localhost"
361
- loopback_addresses.each do |addr|
362
- add_ssl_listener addr, port, ctx, optimize_for_latency, backlog
363
- end
364
- return
365
- end
366
-
367
- host = host[1..-2] if host&.start_with? '['
368
- s = TCPServer.new(host, port)
369
- if optimize_for_latency
370
- s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
371
- end
372
- s.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true)
373
- s.listen backlog
374
-
375
- ssl = MiniSSL::Server.new s, ctx
376
- env = @proto_env.dup
377
- env[HTTPS_KEY] = HTTPS
378
- @envs[ssl] = env
379
-
380
- @ios << ssl
381
- s
382
- end
383
-
384
- def inherit_ssl_listener(fd, ctx)
385
- raise "Puma compiled without SSL support" unless HAS_SSL
386
- # Puma will try to use local authority context if context is supplied nil
387
- ctx ||= localhost_authority_context
388
-
389
- s = fd.kind_of?(::TCPServer) ? fd : ::TCPServer.for_fd(fd)
390
-
391
- ssl = MiniSSL::Server.new(s, ctx)
392
-
393
- env = @proto_env.dup
394
- env[HTTPS_KEY] = HTTPS
395
- @envs[ssl] = env
396
-
397
- @ios << ssl
398
-
399
- s
400
- end
401
-
402
- # Tell the server to listen on +path+ as a UNIX domain socket.
403
- #
404
- def add_unix_listener(path, umask=nil, mode=nil, backlog=1024)
405
- # Let anyone connect by default
406
- umask ||= 0
407
-
408
- begin
409
- old_mask = File.umask(umask)
410
-
411
- if File.exist? path
412
- begin
413
- old = UNIXSocket.new path
414
- rescue SystemCallError, IOError
415
- File.unlink path
416
- else
417
- old.close
418
- raise "There is already a server bound to: #{path}"
419
- end
420
- end
421
- s = UNIXServer.new path.sub(/\A@/, "\0") # check for abstract UNIXSocket
422
- s.listen backlog
423
- @ios << s
424
- ensure
425
- File.umask old_mask
426
- end
427
-
428
- if mode
429
- File.chmod mode, path
430
- end
431
-
432
- env = @proto_env.dup
433
- env[REMOTE_ADDR] = "127.0.0.1"
434
- @envs[s] = env
435
-
436
- s
437
- end
438
-
439
- def inherit_unix_listener(path, fd)
440
- s = fd.kind_of?(::TCPServer) ? fd : ::UNIXServer.for_fd(fd)
441
-
442
- @ios << s
443
-
444
- env = @proto_env.dup
445
- env[REMOTE_ADDR] = "127.0.0.1"
446
- @envs[s] = env
447
-
448
- s
449
- end
450
-
451
- def close_listeners
452
- @listeners.each do |l, io|
453
- begin
454
- io.close unless io.closed?
455
- uri = URI.parse l
456
- next unless uri.scheme == 'unix'
457
- unix_path = "#{uri.host}#{uri.path}"
458
- File.unlink unix_path if @unix_paths.include?(unix_path) && File.exist?(unix_path)
459
- rescue Errno::EBADF
460
- end
461
- end
462
- end
463
-
464
- def redirects_for_restart
465
- redirects = @listeners.map { |a| [a[1].to_i, a[1].to_i] }.to_h
466
- redirects[:close_others] = true
467
- redirects
468
- end
469
-
470
- # @version 5.0.0
471
- def redirects_for_restart_env
472
- @listeners.each_with_object({}).with_index do |(listen, memo), i|
473
- memo["PUMA_INHERIT_#{i}"] = "#{listen[1].to_i}:#{listen[0]}"
474
- end
475
- end
476
-
477
- private
478
-
479
- # @!attribute [r] loopback_addresses
480
- def loopback_addresses
481
- t = Socket.ip_address_list.select do |addrinfo|
482
- addrinfo.ipv6_loopback? || addrinfo.ipv4_loopback?
483
- end
484
- t.map! { |addrinfo| addrinfo.ip_address }; t.uniq!; t
485
- end
486
-
487
- def loc_addr_str(io)
488
- loc_addr = io.to_io.local_address
489
- if loc_addr.ipv6?
490
- "[#{loc_addr.ip_unpack[0]}]:#{loc_addr.ip_unpack[1]}"
491
- else
492
- loc_addr.ip_unpack.join(':')
493
- end
494
- end
495
-
496
- # @version 5.0.0
497
- def socket_activation_fd(int)
498
- int + 3 # 3 is the magic number you add to follow the SA protocol
499
- end
500
- end
501
- end