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/launcher.rb DELETED
@@ -1,484 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'log_writer'
4
- require_relative 'events'
5
- require_relative 'detect'
6
- require_relative 'cluster'
7
- require_relative 'single'
8
- require_relative 'const'
9
- require_relative 'binder'
10
-
11
- module Puma
12
- # Puma::Launcher is the single entry point for starting a Puma server based on user
13
- # configuration. It is responsible for taking user supplied arguments and resolving them
14
- # with configuration in `config/puma.rb` or `config/puma/<env>.rb`.
15
- #
16
- # It is responsible for either launching a cluster of Puma workers or a single
17
- # puma server.
18
- class Launcher
19
- autoload :BundlePruner, 'puma/launcher/bundle_pruner'
20
-
21
- # Returns an instance of Launcher
22
- #
23
- # +conf+ A Puma::Configuration object indicating how to run the server.
24
- #
25
- # +launcher_args+ A Hash that currently has one required key `:events`,
26
- # this is expected to hold an object similar to an `Puma::LogWriter.stdio`,
27
- # this object will be responsible for broadcasting Puma's internal state
28
- # to a logging destination. An optional key `:argv` can be supplied,
29
- # this should be an array of strings, these arguments are re-used when
30
- # restarting the puma server.
31
- #
32
- # Examples:
33
- #
34
- # conf = Puma::Configuration.new do |user_config|
35
- # user_config.threads 1, 10
36
- # user_config.app do |env|
37
- # [200, {}, ["hello world"]]
38
- # end
39
- # end
40
- # Puma::Launcher.new(conf, log_writer: Puma::LogWriter.stdio).run
41
- def initialize(conf, launcher_args={})
42
- @runner = nil
43
- @log_writer = launcher_args[:log_writer] || LogWriter::DEFAULT
44
- @events = launcher_args[:events] || Events.new
45
- @argv = launcher_args[:argv] || []
46
- @original_argv = @argv.dup
47
- @config = conf
48
-
49
- @config.options[:log_writer] = @log_writer
50
-
51
- # Advertise the Configuration
52
- Puma.cli_config = @config if defined?(Puma.cli_config)
53
-
54
- @config.load
55
-
56
- @binder = Binder.new(@log_writer, conf)
57
- @binder.create_inherited_fds(ENV).each { |k| ENV.delete k }
58
- @binder.create_activated_fds(ENV).each { |k| ENV.delete k }
59
-
60
- @environment = conf.environment
61
-
62
- # Load the systemd integration if we detect systemd's NOTIFY_SOCKET.
63
- # Skip this on JRuby though, because it is incompatible with the systemd
64
- # integration due to https://github.com/jruby/jruby/issues/6504
65
- if ENV["NOTIFY_SOCKET"] && !Puma.jruby?
66
- @config.plugins.create('systemd')
67
- end
68
-
69
- if @config.options[:bind_to_activated_sockets]
70
- @config.options[:binds] = @binder.synthesize_binds_from_activated_fs(
71
- @config.options[:binds],
72
- @config.options[:bind_to_activated_sockets] == 'only'
73
- )
74
- end
75
-
76
- @options = @config.options
77
- @config.clamp
78
-
79
- @log_writer.formatter = LogWriter::PidFormatter.new if clustered?
80
- @log_writer.formatter = options[:log_formatter] if @options[:log_formatter]
81
-
82
- @log_writer.custom_logger = options[:custom_logger] if @options[:custom_logger]
83
-
84
- generate_restart_data
85
-
86
- if clustered? && !Puma.forkable?
87
- unsupported "worker mode not supported on #{RUBY_ENGINE} on this platform"
88
- end
89
-
90
- Dir.chdir(@restart_dir)
91
-
92
- prune_bundler!
93
-
94
- @environment = @options[:environment] if @options[:environment]
95
- set_rack_environment
96
-
97
- if clustered?
98
- @options[:logger] = @log_writer
99
-
100
- @runner = Cluster.new(self)
101
- else
102
- @runner = Single.new(self)
103
- end
104
- Puma.stats_object = @runner
105
-
106
- @status = :run
107
-
108
- log_config if ENV['PUMA_LOG_CONFIG']
109
- end
110
-
111
- attr_reader :binder, :log_writer, :events, :config, :options, :restart_dir
112
-
113
- # Return stats about the server
114
- def stats
115
- @runner.stats
116
- end
117
-
118
- # Write a state file that can be used by pumactl to control
119
- # the server
120
- def write_state
121
- write_pid
122
-
123
- path = @options[:state]
124
- permission = @options[:state_permission]
125
- return unless path
126
-
127
- require_relative 'state_file'
128
-
129
- sf = StateFile.new
130
- sf.pid = Process.pid
131
- sf.control_url = @options[:control_url]
132
- sf.control_auth_token = @options[:control_auth_token]
133
- sf.running_from = File.expand_path('.')
134
-
135
- sf.save path, permission
136
- end
137
-
138
- # Delete the configured pidfile
139
- def delete_pidfile
140
- path = @options[:pidfile]
141
- File.unlink(path) if path && File.exist?(path)
142
- end
143
-
144
- # Begin async shutdown of the server
145
- def halt
146
- @status = :halt
147
- @runner.halt
148
- end
149
-
150
- # Begin async shutdown of the server gracefully
151
- def stop
152
- @status = :stop
153
- @runner.stop
154
- end
155
-
156
- # Begin async restart of the server
157
- def restart
158
- @status = :restart
159
- @runner.restart
160
- end
161
-
162
- # Begin a phased restart if supported
163
- def phased_restart
164
- unless @runner.respond_to?(:phased_restart) and @runner.phased_restart
165
- log "* phased-restart called but not available, restarting normally."
166
- return restart
167
- end
168
- true
169
- end
170
-
171
- # Begin a refork if supported
172
- def refork
173
- if clustered? && @runner.respond_to?(:fork_worker!) && @options[:fork_worker]
174
- @runner.fork_worker!
175
- true
176
- else
177
- log "* refork called but not available."
178
- false
179
- end
180
- end
181
-
182
- # Run the server. This blocks until the server is stopped
183
- def run
184
- previous_env = get_env
185
-
186
- @config.clamp
187
-
188
- @config.plugins.fire_starts self
189
-
190
- setup_signals
191
- set_process_title
192
-
193
- # This blocks until the server is stopped
194
- @runner.run
195
-
196
- do_run_finished(previous_env)
197
- end
198
-
199
- # Return all tcp ports the launcher may be using, TCP or SSL
200
- # @!attribute [r] connected_ports
201
- # @version 5.0.0
202
- def connected_ports
203
- @binder.connected_ports
204
- end
205
-
206
- # @!attribute [r] restart_args
207
- def restart_args
208
- cmd = @options[:restart_cmd]
209
- if cmd
210
- cmd.split(' ') + @original_argv
211
- else
212
- @restart_argv
213
- end
214
- end
215
-
216
- def close_binder_listeners
217
- @runner.close_control_listeners
218
- @binder.close_listeners
219
- unless @status == :restart
220
- log "=== puma shutdown: #{Time.now} ==="
221
- log "- Goodbye!"
222
- end
223
- end
224
-
225
- # @!attribute [r] thread_status
226
- # @version 5.0.0
227
- def thread_status
228
- Thread.list.each do |thread|
229
- name = "Thread: TID-#{thread.object_id.to_s(36)}"
230
- name += " #{thread['label']}" if thread['label']
231
- name += " #{thread.name}" if thread.respond_to?(:name) && thread.name
232
- backtrace = thread.backtrace || ["<no backtrace available>"]
233
-
234
- yield name, backtrace
235
- end
236
- end
237
-
238
- private
239
-
240
- def get_env
241
- if defined?(Bundler)
242
- env = Bundler::ORIGINAL_ENV.dup
243
- # add -rbundler/setup so we load from Gemfile when restarting
244
- bundle = "-rbundler/setup"
245
- env["RUBYOPT"] = [env["RUBYOPT"], bundle].join(" ").lstrip unless env["RUBYOPT"].to_s.include?(bundle)
246
- env
247
- else
248
- ENV.to_h
249
- end
250
- end
251
-
252
- def do_run_finished(previous_env)
253
- case @status
254
- when :halt
255
- do_forceful_stop
256
- when :run, :stop
257
- do_graceful_stop
258
- when :restart
259
- do_restart(previous_env)
260
- end
261
-
262
- close_binder_listeners unless @status == :restart
263
- end
264
-
265
- def do_forceful_stop
266
- log "* Stopping immediately!"
267
- @runner.stop_control
268
- end
269
-
270
- def do_graceful_stop
271
- @events.fire_on_stopped!
272
- @runner.stop_blocked
273
- end
274
-
275
- def do_restart(previous_env)
276
- log "* Restarting..."
277
- ENV.replace(previous_env)
278
- @runner.stop_control
279
- restart!
280
- end
281
-
282
- def restart!
283
- @events.fire_on_restart!
284
- @config.run_hooks :on_restart, self, @log_writer
285
-
286
- if Puma.jruby?
287
- close_binder_listeners
288
-
289
- require_relative 'jruby_restart'
290
- JRubyRestart.chdir_exec(@restart_dir, restart_args)
291
- elsif Puma.windows?
292
- close_binder_listeners
293
-
294
- argv = restart_args
295
- Dir.chdir(@restart_dir)
296
- Kernel.exec(*argv)
297
- else
298
- argv = restart_args
299
- Dir.chdir(@restart_dir)
300
- ENV.update(@binder.redirects_for_restart_env)
301
- argv += [@binder.redirects_for_restart]
302
- Kernel.exec(*argv)
303
- end
304
- end
305
-
306
- # If configured, write the pid of the current process out
307
- # to a file.
308
- def write_pid
309
- path = @options[:pidfile]
310
- return unless path
311
- cur_pid = Process.pid
312
- File.write path, cur_pid, mode: 'wb:UTF-8'
313
- at_exit do
314
- delete_pidfile if cur_pid == Process.pid
315
- end
316
- end
317
-
318
- def reload_worker_directory
319
- @runner.reload_worker_directory if @runner.respond_to?(:reload_worker_directory)
320
- end
321
-
322
- def log(str)
323
- @log_writer.log(str)
324
- end
325
-
326
- def clustered?
327
- (@options[:workers] || 0) > 0
328
- end
329
-
330
- def unsupported(str)
331
- @log_writer.error(str)
332
- raise UnsupportedOption
333
- end
334
-
335
- def set_process_title
336
- Process.respond_to?(:setproctitle) ? Process.setproctitle(title) : $0 = title
337
- end
338
-
339
- # @!attribute [r] title
340
- def title
341
- buffer = "puma #{Puma::Const::VERSION} (#{@options[:binds].join(',')})"
342
- buffer += " [#{@options[:tag]}]" if @options[:tag] && !@options[:tag].empty?
343
- buffer
344
- end
345
-
346
- def set_rack_environment
347
- @options[:environment] = environment
348
- ENV['RACK_ENV'] = environment
349
- end
350
-
351
- # @!attribute [r] environment
352
- def environment
353
- @environment
354
- end
355
-
356
- def prune_bundler?
357
- @options[:prune_bundler] && clustered? && !@options[:preload_app]
358
- end
359
-
360
- def prune_bundler!
361
- return unless prune_bundler?
362
- BundlePruner.new(@original_argv, @options[:extra_runtime_dependencies], @log_writer).prune
363
- end
364
-
365
- def generate_restart_data
366
- if dir = @options[:directory]
367
- @restart_dir = dir
368
-
369
- elsif Puma.windows?
370
- # I guess the value of PWD is garbage on windows so don't bother
371
- # using it.
372
- @restart_dir = Dir.pwd
373
-
374
- # Use the same trick as unicorn, namely favor PWD because
375
- # it will contain an unresolved symlink, useful for when
376
- # the pwd is /data/releases/current.
377
- elsif dir = ENV['PWD']
378
- s_env = File.stat(dir)
379
- s_pwd = File.stat(Dir.pwd)
380
-
381
- if s_env.ino == s_pwd.ino and (Puma.jruby? or s_env.dev == s_pwd.dev)
382
- @restart_dir = dir
383
- end
384
- end
385
-
386
- @restart_dir ||= Dir.pwd
387
-
388
- # if $0 is a file in the current directory, then restart
389
- # it the same, otherwise add -S on there because it was
390
- # picked up in PATH.
391
- #
392
- if File.exist?($0)
393
- arg0 = [Gem.ruby, $0]
394
- else
395
- arg0 = [Gem.ruby, "-S", $0]
396
- end
397
-
398
- # Detect and reinject -Ilib from the command line, used for testing without bundler
399
- # cruby has an expanded path, jruby has just "lib"
400
- lib = File.expand_path "lib"
401
- arg0[1,0] = ["-I", lib] if [lib, "lib"].include?($LOAD_PATH[0])
402
-
403
- if defined? Puma::WILD_ARGS
404
- @restart_argv = arg0 + Puma::WILD_ARGS + @original_argv
405
- else
406
- @restart_argv = arg0 + @original_argv
407
- end
408
- end
409
-
410
- def setup_signals
411
- begin
412
- Signal.trap "SIGUSR2" do
413
- restart
414
- end
415
- rescue Exception
416
- log "*** SIGUSR2 not implemented, signal based restart unavailable!"
417
- end
418
-
419
- unless Puma.jruby?
420
- begin
421
- Signal.trap "SIGUSR1" do
422
- phased_restart
423
- end
424
- rescue Exception
425
- log "*** SIGUSR1 not implemented, signal based restart unavailable!"
426
- end
427
- end
428
-
429
- begin
430
- Signal.trap "SIGTERM" do
431
- # Shortcut the control flow in case raise_exception_on_sigterm is true
432
- do_graceful_stop
433
-
434
- raise(SignalException, "SIGTERM") if @options[:raise_exception_on_sigterm]
435
- end
436
- rescue Exception
437
- log "*** SIGTERM not implemented, signal based gracefully stopping unavailable!"
438
- end
439
-
440
- begin
441
- Signal.trap "SIGINT" do
442
- stop
443
- end
444
- rescue Exception
445
- log "*** SIGINT not implemented, signal based gracefully stopping unavailable!"
446
- end
447
-
448
- begin
449
- Signal.trap "SIGHUP" do
450
- if @runner.redirected_io?
451
- @runner.redirect_io
452
- else
453
- stop
454
- end
455
- end
456
- rescue Exception
457
- log "*** SIGHUP not implemented, signal based logs reopening unavailable!"
458
- end
459
-
460
- begin
461
- unless Puma.jruby? # INFO in use by JVM already
462
- Signal.trap "SIGINFO" do
463
- thread_status do |name, backtrace|
464
- @log_writer.log(name)
465
- @log_writer.log(backtrace.map { |bt| " #{bt}" })
466
- end
467
- end
468
- end
469
- rescue Exception
470
- # Not going to log this one, as SIGINFO is *BSD only and would be pretty annoying
471
- # to see this constantly on Linux.
472
- end
473
- end
474
-
475
- def log_config
476
- log "Configuration:"
477
-
478
- @config.final_options
479
- .each { |config_key, value| log "- #{config_key}: #{value}" }
480
-
481
- log "\n"
482
- end
483
- end
484
- end
@@ -1,147 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'null_io'
4
- require_relative 'error_logger'
5
- require 'stringio'
6
- require 'io/wait' unless Puma::HAS_NATIVE_IO_WAIT
7
-
8
- module Puma
9
-
10
- # Handles logging concerns for both standard messages
11
- # (+stdout+) and errors (+stderr+).
12
- class LogWriter
13
-
14
- class DefaultFormatter
15
- def call(str)
16
- str
17
- end
18
- end
19
-
20
- class PidFormatter
21
- def call(str)
22
- "[#{$$}] #{str}"
23
- end
24
- end
25
-
26
- LOG_QUEUE = Queue.new
27
-
28
- attr_reader :stdout,
29
- :stderr
30
-
31
- attr_accessor :formatter, :custom_logger
32
-
33
- # Create a LogWriter that prints to +stdout+ and +stderr+.
34
- def initialize(stdout, stderr)
35
- @formatter = DefaultFormatter.new
36
- @custom_logger = nil
37
- @stdout = stdout
38
- @stderr = stderr
39
-
40
- @debug = ENV.key?('PUMA_DEBUG')
41
- @error_logger = ErrorLogger.new(@stderr)
42
- end
43
-
44
- DEFAULT = new(STDOUT, STDERR)
45
-
46
- # Returns an LogWriter object which writes its status to
47
- # two StringIO objects.
48
- def self.strings
49
- LogWriter.new(StringIO.new, StringIO.new)
50
- end
51
-
52
- def self.stdio
53
- LogWriter.new($stdout, $stderr)
54
- end
55
-
56
- def self.null
57
- n = NullIO.new
58
- LogWriter.new(n, n)
59
- end
60
-
61
- # Write +str+ to +@stdout+
62
- def log(str)
63
- if @custom_logger&.respond_to?(:write)
64
- @custom_logger.write(format(str))
65
- else
66
- internal_write "#{@formatter.call str}\n"
67
- end
68
- end
69
-
70
- def write(str)
71
- internal_write @formatter.call(str)
72
- end
73
-
74
- def internal_write(str)
75
- LOG_QUEUE << str
76
- while (w_str = LOG_QUEUE.pop(true)) do
77
- begin
78
- @stdout.is_a?(IO) and @stdout.wait_writable(1)
79
- @stdout.write w_str
80
- @stdout.flush unless @stdout.sync
81
- rescue Errno::EPIPE, Errno::EBADF, IOError, Errno::EINVAL
82
- # 'Invalid argument' (Errno::EINVAL) may be raised by flush
83
- end
84
- end
85
- rescue ThreadError
86
- end
87
- private :internal_write
88
-
89
- def debug?
90
- @debug
91
- end
92
-
93
- def debug(str)
94
- log("% #{str}") if @debug
95
- end
96
-
97
- # Write +str+ to +@stderr+
98
- def error(str)
99
- @error_logger.info(text: @formatter.call("ERROR: #{str}"))
100
- exit 1
101
- end
102
-
103
- def format(str)
104
- formatter.call(str)
105
- end
106
-
107
- # An HTTP connection error has occurred.
108
- # +error+ a connection exception, +req+ the request,
109
- # and +text+ additional info
110
- # @version 5.0.0
111
- def connection_error(error, req, text="HTTP connection error")
112
- @error_logger.info(error: error, req: req, text: text)
113
- end
114
-
115
- # An HTTP parse error has occurred.
116
- # +error+ a parsing exception,
117
- # and +req+ the request.
118
- def parse_error(error, req)
119
- @error_logger.info(error: error, req: req, text: 'HTTP parse error, malformed request')
120
- end
121
-
122
- # An SSL error has occurred.
123
- # @param error <Puma::MiniSSL::SSLError>
124
- # @param ssl_socket <Puma::MiniSSL::Socket>
125
- def ssl_error(error, ssl_socket)
126
- peeraddr = ssl_socket.peeraddr.last rescue "<unknown>"
127
- peercert = ssl_socket.peercert
128
- subject = peercert&.subject
129
- @error_logger.info(error: error, text: "SSL error, peer: #{peeraddr}, peer cert: #{subject}")
130
- end
131
-
132
- # An unknown error has occurred.
133
- # +error+ an exception object, +req+ the request,
134
- # and +text+ additional info
135
- def unknown_error(error, req=nil, text="Unknown error")
136
- @error_logger.info(error: error, req: req, text: text)
137
- end
138
-
139
- # Log occurred error debug dump.
140
- # +error+ an exception object, +req+ the request,
141
- # and +text+ additional info
142
- # @version 5.0.0
143
- def debug_error(error, req=nil, text="")
144
- @error_logger.debug(error: error, req: req, text: text)
145
- end
146
- end
147
- end