puma 6.4.3-java → 6.5.0-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.
data/lib/puma/dsl.rb CHANGED
@@ -51,7 +51,8 @@ module Puma
51
51
  class DSL
52
52
  ON_WORKER_KEY = [String, Symbol].freeze
53
53
 
54
- # convenience method so logic can be used in CI
54
+ # Convenience method so logic can be used in CI.
55
+ #
55
56
  # @see ssl_bind
56
57
  #
57
58
  def self.ssl_bind_str(host, port, opts)
@@ -85,6 +86,7 @@ module Puma
85
86
  "&verify_mode=#{verify}#{tls_str}#{ca_additions}#{backlog_str}"
86
87
  else
87
88
  ssl_cipher_filter = opts[:ssl_cipher_filter] ? "&ssl_cipher_filter=#{opts[:ssl_cipher_filter]}" : nil
89
+ ssl_ciphersuites = opts[:ssl_ciphersuites] ? "&ssl_ciphersuites=#{opts[:ssl_ciphersuites]}" : nil
88
90
  v_flags = (ary = opts[:verification_flags]) ? "&verification_flags=#{Array(ary).join ','}" : nil
89
91
 
90
92
  cert_flags = (cert = opts[:cert]) ? "cert=#{Puma::Util.escape(cert)}" : nil
@@ -115,7 +117,7 @@ module Puma
115
117
  nil
116
118
  end
117
119
 
118
- "ssl://#{host}:#{port}?#{cert_flags}#{key_flags}#{password_flags}#{ssl_cipher_filter}" \
120
+ "ssl://#{host}:#{port}?#{cert_flags}#{key_flags}#{password_flags}#{ssl_cipher_filter}#{ssl_ciphersuites}" \
119
121
  "#{reuse_flag}&verify_mode=#{verify}#{tls_str}#{ca_additions}#{v_flags}#{backlog_str}#{low_latency_str}"
120
122
  end
121
123
  end
@@ -163,7 +165,10 @@ module Puma
163
165
  @options[key.to_sym] || default
164
166
  end
165
167
 
166
- # Load the named plugin for use by this configuration
168
+ # Load the named plugin for use by this configuration.
169
+ #
170
+ # @example
171
+ # plugin :tmp_restart
167
172
  #
168
173
  def plugin(name)
169
174
  @plugins << @config.load_plugin(name)
@@ -210,6 +215,7 @@ module Puma
210
215
  # activate_control_app 'unix:///var/run/pumactl.sock', { auth_token: '12345' }
211
216
  # @example
212
217
  # activate_control_app 'unix:///var/run/pumactl.sock', { no_token: true }
218
+ #
213
219
  def activate_control_app(url="auto", opts={})
214
220
  if url == "auto"
215
221
  path = Configuration.temp_path
@@ -235,8 +241,12 @@ module Puma
235
241
  @options[:control_url_umask] = opts[:umask] if opts[:umask]
236
242
  end
237
243
 
238
- # Load additional configuration from a file
239
- # Files get loaded later via Configuration#load
244
+ # Load additional configuration from a file.
245
+ # Files get loaded later via Configuration#load.
246
+ #
247
+ # @example
248
+ # load 'config/puma/production.rb'
249
+ #
240
250
  def load(file)
241
251
  @options[:config_files] ||= []
242
252
  @options[:config_files] << file
@@ -268,6 +278,7 @@ module Puma
268
278
  # bind 'tcp://0.0.0.0:9292?low_latency=false'
269
279
  # @example Socket permissions
270
280
  # bind 'unix:///var/run/puma.sock?umask=0111'
281
+ #
271
282
  # @see Puma::Runner#load_and_bind
272
283
  # @see Puma::Cluster#run
273
284
  #
@@ -302,39 +313,70 @@ module Puma
302
313
  #
303
314
  # @example Only bind to systemd activated sockets, ignoring other binds
304
315
  # bind_to_activated_sockets 'only'
316
+ #
305
317
  def bind_to_activated_sockets(bind=true)
306
318
  @options[:bind_to_activated_sockets] = bind
307
319
  end
308
320
 
309
- # Define the TCP port to bind to. Use +bind+ for more advanced options.
321
+ # Define the TCP port to bind to. Use `bind` for more advanced options.
322
+ #
323
+ # The default is +9292+.
310
324
  #
311
325
  # @example
312
- # port 9292
326
+ # port 3000
327
+ #
313
328
  def port(port, host=nil)
314
329
  host ||= default_host
315
330
  bind URI::Generic.build(scheme: 'tcp', host: host, port: Integer(port)).to_s
316
331
  end
317
332
 
318
333
  # Define how long the tcp socket stays open, if no data has been received.
334
+ #
335
+ # The default is 30 seconds.
336
+ #
337
+ # @example
338
+ # first_data_timeout 40
339
+ #
319
340
  # @see Puma::Server.new
341
+ #
320
342
  def first_data_timeout(seconds)
321
343
  @options[:first_data_timeout] = Integer(seconds)
322
344
  end
323
345
 
324
346
  # Define how long persistent connections can be idle before Puma closes them.
347
+ #
348
+ # The default is 20 seconds.
349
+ #
350
+ # @example
351
+ # persistent_timeout 30
352
+ #
325
353
  # @see Puma::Server.new
354
+ #
326
355
  def persistent_timeout(seconds)
327
356
  @options[:persistent_timeout] = Integer(seconds)
328
357
  end
329
358
 
330
359
  # If a new request is not received within this number of seconds, begin shutting down.
360
+ #
361
+ # The default is +nil+.
362
+ #
363
+ # @example
364
+ # idle_timeout 60
365
+ #
331
366
  # @see Puma::Server.new
367
+ #
332
368
  def idle_timeout(seconds)
333
369
  @options[:idle_timeout] = Integer(seconds)
334
370
  end
335
371
 
336
372
  # Work around leaky apps that leave garbage in Thread locals
337
373
  # across requests.
374
+ #
375
+ # The default is +false+.
376
+ #
377
+ # @example
378
+ # clean_thread_locals
379
+ #
338
380
  def clean_thread_locals(which=true)
339
381
  @options[:clean_thread_locals] = which
340
382
  end
@@ -342,6 +384,7 @@ module Puma
342
384
  # When shutting down, drain the accept socket of pending connections and
343
385
  # process them. This loops over the accept socket until there are no more
344
386
  # read events and then stops looking and waits for the requests to finish.
387
+ #
345
388
  # @see Puma::Server#graceful_shutdown
346
389
  #
347
390
  def drain_on_shutdown(which=true)
@@ -355,18 +398,22 @@ module Puma
355
398
  #
356
399
  # @example
357
400
  # environment 'production'
401
+ #
358
402
  def environment(environment)
359
403
  @options[:environment] = environment
360
404
  end
361
405
 
362
- # How long to wait for threads to stop when shutting them
363
- # down. Defaults to :forever. Specifying :immediately will cause
364
- # Puma to kill the threads immediately. Otherwise the value
365
- # is the number of seconds to wait.
406
+ # How long to wait for threads to stop when shutting them down.
407
+ # Specifying :immediately will cause Puma to kill the threads immediately.
408
+ # Otherwise the value is the number of seconds to wait.
366
409
  #
367
410
  # Puma always waits a few seconds after killing a thread for it to try
368
411
  # to finish up it's work, even in :immediately mode.
412
+ #
413
+ # The default is +:forever+.
414
+ #
369
415
  # @see Puma::Server#graceful_shutdown
416
+ #
370
417
  def force_shutdown_after(val=:forever)
371
418
  i = case val
372
419
  when :forever
@@ -389,6 +436,7 @@ module Puma
389
436
  # on_restart do
390
437
  # puts 'On restart...'
391
438
  # end
439
+ #
392
440
  def on_restart(&block)
393
441
  @options[:on_restart] ||= []
394
442
  @options[:on_restart] << block
@@ -400,6 +448,7 @@ module Puma
400
448
  #
401
449
  # @example
402
450
  # restart_command '/u/app/lolcat/bin/restart_puma'
451
+ #
403
452
  def restart_command(cmd)
404
453
  @options[:restart_cmd] = cmd.to_s
405
454
  end
@@ -408,31 +457,49 @@ module Puma
408
457
  #
409
458
  # @example
410
459
  # pidfile '/u/apps/lolcat/tmp/pids/puma.pid'
460
+ #
411
461
  def pidfile(path)
412
462
  @options[:pidfile] = path.to_s
413
463
  end
414
464
 
415
- # Disable request logging, if this isn't used it'll be enabled by default.
465
+ # Disable request logging, the inverse of `log_requests`.
466
+ #
467
+ # The default is +true+.
416
468
  #
417
469
  # @example
418
470
  # quiet
471
+ #
419
472
  def quiet(which=true)
420
473
  @options[:log_requests] = !which
421
474
  end
422
475
 
423
- # Enable request logging
476
+ # Enable request logging, the inverse of `quiet`.
477
+ #
478
+ # The default is +false+.
479
+ #
480
+ # @example
481
+ # log_requests
424
482
  #
425
483
  def log_requests(which=true)
426
484
  @options[:log_requests] = which
427
485
  end
428
486
 
429
487
  # Pass in a custom logging class instance
488
+ #
489
+ # @example
490
+ # custom_logger Logger.new('t.log')
491
+ #
430
492
  def custom_logger(custom_logger)
431
493
  @options[:custom_logger] = custom_logger
432
494
  end
433
495
 
434
496
  # Show debugging info
435
497
  #
498
+ # The default is +false+.
499
+ #
500
+ # @example
501
+ # debug
502
+ #
436
503
  def debug
437
504
  @options[:debug] = true
438
505
  end
@@ -443,6 +510,7 @@ module Puma
443
510
  #
444
511
  # @example
445
512
  # rackup '/u/apps/lolcat/config.ru'
513
+ #
446
514
  def rackup(path)
447
515
  @options[:rackup] ||= path.to_s
448
516
  end
@@ -450,21 +518,32 @@ module Puma
450
518
  # Allows setting `env['rack.url_scheme']`.
451
519
  # Only necessary if X-Forwarded-Proto is not being set by your proxy
452
520
  # Normal values are 'http' or 'https'.
521
+ #
453
522
  def rack_url_scheme(scheme=nil)
454
523
  @options[:rack_url_scheme] = scheme
455
524
  end
456
525
 
526
+ # Enable HTTP 103 Early Hints responses.
527
+ #
528
+ # The default is +nil+.
529
+ #
530
+ # @example
531
+ # early_hints
532
+ #
457
533
  def early_hints(answer=true)
458
534
  @options[:early_hints] = answer
459
535
  end
460
536
 
461
537
  # Redirect +STDOUT+ and +STDERR+ to files specified. The +append+ parameter
462
- # specifies whether the output is appended, the default is +false+.
538
+ # specifies whether the output is appended.
539
+ #
540
+ # The default is +false+.
463
541
  #
464
542
  # @example
465
543
  # stdout_redirect '/app/lolcat/log/stdout', '/app/lolcat/log/stderr'
466
544
  # @example
467
545
  # stdout_redirect '/app/lolcat/log/stdout', '/app/lolcat/log/stderr', true
546
+ #
468
547
  def stdout_redirect(stdout=nil, stderr=nil, append=false)
469
548
  @options[:redirect_stdout] = stdout
470
549
  @options[:redirect_stderr] = stderr
@@ -475,8 +554,9 @@ module Puma
475
554
  @options[:log_formatter] = block
476
555
  end
477
556
 
478
- # Configure +min+ to be the minimum number of threads to use to answer
479
- # requests and +max+ the maximum.
557
+ # Configure the number of threads to use to answer requests.
558
+ #
559
+ # It can be a single fixed number, or a +min+ and a +max+.
480
560
  #
481
561
  # The default is the environment variables +PUMA_MIN_THREADS+ / +PUMA_MAX_THREADS+
482
562
  # (or +MIN_THREADS+ / +MAX_THREADS+ if the +PUMA_+ variables aren't set).
@@ -484,10 +564,13 @@ module Puma
484
564
  # If these environment variables aren't set, the default is "0, 5" in MRI or "0, 16" for other interpreters.
485
565
  #
486
566
  # @example
567
+ # threads 5
568
+ # @example
487
569
  # threads 0, 16
488
570
  # @example
489
571
  # threads 5, 5
490
- def threads(min, max)
572
+ #
573
+ def threads(min, max = min)
491
574
  min = Integer(min)
492
575
  max = Integer(max)
493
576
  if min > max
@@ -527,6 +610,7 @@ module Puma
527
610
  # cert: path_to_cert,
528
611
  # key: path_to_key,
529
612
  # ssl_cipher_filter: cipher_filter, # optional
613
+ # ssl_ciphersuites: ciphersuites, # optional
530
614
  # verify_mode: verify_mode, # default 'none'
531
615
  # verification_flags: flags, # optional, not supported by JRuby
532
616
  # reuse: true # optional
@@ -549,6 +633,7 @@ module Puma
549
633
  # ssl_cipher_list: cipher_list, # optional
550
634
  # verify_mode: verify_mode # default 'none'
551
635
  # }
636
+ #
552
637
  def ssl_bind(host, port, opts = {})
553
638
  add_pem_values_to_options_store(opts)
554
639
  bind self.class.ssl_bind_str(host, port, opts)
@@ -559,6 +644,7 @@ module Puma
559
644
  #
560
645
  # @example
561
646
  # state_path '/u/apps/lolcat/tmp/pids/puma.state'
647
+ #
562
648
  def state_path(path)
563
649
  @options[:state] = path.to_s
564
650
  end
@@ -567,6 +653,7 @@ module Puma
567
653
  #
568
654
  # @example
569
655
  # state_permission 0600
656
+ #
570
657
  # @version 5.0.0
571
658
  #
572
659
  def state_permission(permission)
@@ -580,7 +667,12 @@ module Puma
580
667
  # set, otherwise 0.
581
668
  #
582
669
  # @note Cluster mode only.
670
+ #
671
+ # @example
672
+ # workers 2
673
+ #
583
674
  # @see Puma::Cluster
675
+ #
584
676
  def workers(count)
585
677
  @options[:workers] = count.to_i
586
678
  end
@@ -598,12 +690,24 @@ module Puma
598
690
  #
599
691
  # Moving from workers = 1 to workers = 0 will save 10-30% of memory use.
600
692
  #
693
+ # The default is +false+.
694
+ #
601
695
  # @note Cluster mode only.
696
+ #
697
+ # @example
698
+ # silence_single_worker_warning
699
+ #
602
700
  def silence_single_worker_warning
603
701
  @options[:silence_single_worker_warning] = true
604
702
  end
605
703
 
606
704
  # Disable warning message when running single mode with callback hook defined.
705
+ #
706
+ # The default is +false+.
707
+ #
708
+ # @example
709
+ # silence_fork_callback_warning
710
+ #
607
711
  def silence_fork_callback_warning
608
712
  @options[:silence_fork_callback_warning] = true
609
713
  end
@@ -618,10 +722,12 @@ module Puma
618
722
  # This can be called multiple times to add several hooks.
619
723
  #
620
724
  # @note Cluster mode only.
725
+ #
621
726
  # @example
622
727
  # before_fork do
623
728
  # puts "Starting workers..."
624
729
  # end
730
+ #
625
731
  def before_fork(&block)
626
732
  warn_if_in_single_mode('before_fork')
627
733
 
@@ -635,10 +741,12 @@ module Puma
635
741
  # This can be called multiple times to add several hooks.
636
742
  #
637
743
  # @note Cluster mode only.
744
+ #
638
745
  # @example
639
746
  # on_worker_boot do
640
747
  # puts 'Before worker boot...'
641
748
  # end
749
+ #
642
750
  def on_worker_boot(key = nil, &block)
643
751
  warn_if_in_single_mode('on_worker_boot')
644
752
 
@@ -646,17 +754,20 @@ module Puma
646
754
  end
647
755
 
648
756
  # Code to run immediately before a worker shuts
649
- # down (after it has finished processing HTTP requests). These hooks
757
+ # down (after it has finished processing HTTP requests). The worker's
758
+ # index is passed as an argument. These hooks
650
759
  # can block if necessary to wait for background operations unknown
651
760
  # to Puma to finish before the process terminates.
652
761
  #
653
762
  # This can be called multiple times to add several hooks.
654
763
  #
655
764
  # @note Cluster mode only.
765
+ #
656
766
  # @example
657
767
  # on_worker_shutdown do
658
768
  # puts 'On worker shutdown...'
659
769
  # end
770
+ #
660
771
  def on_worker_shutdown(key = nil, &block)
661
772
  warn_if_in_single_mode('on_worker_shutdown')
662
773
 
@@ -669,10 +780,12 @@ module Puma
669
780
  # This can be called multiple times to add several hooks.
670
781
  #
671
782
  # @note Cluster mode only.
783
+ #
672
784
  # @example
673
785
  # on_worker_fork do
674
786
  # puts 'Before worker fork...'
675
787
  # end
788
+ #
676
789
  def on_worker_fork(&block)
677
790
  warn_if_in_single_mode('on_worker_fork')
678
791
 
@@ -685,10 +798,12 @@ module Puma
685
798
  # This is called everytime a worker is to be started.
686
799
  #
687
800
  # @note Cluster mode only.
801
+ #
688
802
  # @example
689
803
  # after_worker_fork do
690
804
  # puts 'After worker fork...'
691
805
  # end
806
+ #
692
807
  def after_worker_fork(&block)
693
808
  warn_if_in_single_mode('after_worker_fork')
694
809
 
@@ -703,10 +818,22 @@ module Puma
703
818
  # on_booted do
704
819
  # puts 'After booting...'
705
820
  # end
821
+ #
706
822
  def on_booted(&block)
707
823
  @config.options[:events].on_booted(&block)
708
824
  end
709
825
 
826
+ # Code to run after puma is stopped (works for both: single and clustered)
827
+ #
828
+ # @example
829
+ # on_stopped do
830
+ # puts 'After stopping...'
831
+ # end
832
+ #
833
+ def on_stopped(&block)
834
+ @config.options[:events].on_stopped(&block)
835
+ end
836
+
710
837
  # When `fork_worker` is enabled, code to run in Worker 0
711
838
  # before all other workers are re-forked from this process,
712
839
  # after the server has temporarily stopped serving requests
@@ -719,10 +846,12 @@ module Puma
719
846
  # This can be called multiple times to add several hooks.
720
847
  #
721
848
  # @note Cluster mode with `fork_worker` enabled only.
849
+ #
722
850
  # @example
723
851
  # on_refork do
724
852
  # 3.times {GC.start}
725
853
  # end
854
+ #
726
855
  # @version 5.0.0
727
856
  #
728
857
  def on_refork(key = nil, &block)
@@ -745,6 +874,7 @@ module Puma
745
874
  # on_thread_start do
746
875
  # puts 'On thread start...'
747
876
  # end
877
+ #
748
878
  def on_thread_start(&block)
749
879
  @options[:before_thread_start] ||= []
750
880
  @options[:before_thread_start] << block
@@ -769,6 +899,7 @@ module Puma
769
899
  # on_thread_exit do
770
900
  # puts 'On thread exit...'
771
901
  # end
902
+ #
772
903
  def on_thread_exit(&block)
773
904
  @options[:before_thread_exit] ||= []
774
905
  @options[:before_thread_exit] << block
@@ -783,6 +914,7 @@ module Puma
783
914
  # or scheduling asynchronous tasks to execute after a response.
784
915
  #
785
916
  # This can be called multiple times to add several hooks.
917
+ #
786
918
  def out_of_band(&block)
787
919
  process_hook :out_of_band, nil, block, 'out_of_band'
788
920
  end
@@ -793,16 +925,21 @@ module Puma
793
925
  #
794
926
  # @example
795
927
  # directory '/u/apps/lolcat'
928
+ #
796
929
  def directory(dir)
797
930
  @options[:directory] = dir.to_s
798
931
  end
799
932
 
800
933
  # Preload the application before starting the workers; this conflicts with
801
- # phased restart feature. On by default if your app uses more than 1 worker.
934
+ # phased restart feature.
935
+ #
936
+ # The default is +true+ if your app uses more than 1 worker.
802
937
  #
803
938
  # @note Cluster mode only.
939
+ #
804
940
  # @example
805
941
  # preload_app!
942
+ #
806
943
  def preload_app!(answer=true)
807
944
  @options[:preload_app] = answer
808
945
  end
@@ -814,6 +951,7 @@ module Puma
814
951
  # lowlevel_error_handler do |err|
815
952
  # [200, {}, ["error page"]]
816
953
  # end
954
+ #
817
955
  def lowlevel_error_handler(obj=nil, &block)
818
956
  obj ||= block
819
957
  raise "Provide either a #call'able or a block" unless obj
@@ -833,23 +971,26 @@ module Puma
833
971
  # new Bundler context and thus can float around as the release
834
972
  # dictates.
835
973
  #
836
- # @see extra_runtime_dependencies
837
- #
838
974
  # @note This is incompatible with +preload_app!+.
839
975
  # @note This is only supported for RubyGems 2.2+
976
+ #
977
+ # @see extra_runtime_dependencies
978
+ #
840
979
  def prune_bundler(answer=true)
841
980
  @options[:prune_bundler] = answer
842
981
  end
843
982
 
844
- # By default, Puma will raise SignalException when SIGTERM is received. In
845
- # environments where SIGTERM is something expected, you can suppress these
846
- # with this option.
983
+ # Raises a SignalException when SIGTERM is received. In environments where
984
+ # SIGTERM is something expected, you can suppress these with this option.
847
985
  #
848
986
  # This can be useful for example in Kubernetes, where rolling restart is
849
- # guaranteed usually on infrastructure level.
987
+ # guaranteed usually on the infrastructure level.
988
+ #
989
+ # The default is +true+.
850
990
  #
851
991
  # @example
852
992
  # raise_exception_on_sigterm false
993
+ #
853
994
  # @see Puma::Launcher#setup_signals
854
995
  # @see Puma::Cluster#setup_signals
855
996
  #
@@ -868,6 +1009,7 @@ module Puma
868
1009
  # extra_runtime_dependencies ['gem_name_1', 'gem_name_2']
869
1010
  # @example
870
1011
  # extra_runtime_dependencies ['puma_worker_killer', 'puma-heroku']
1012
+ #
871
1013
  # @see Puma::Launcher#extra_runtime_deps_directories
872
1014
  #
873
1015
  def extra_runtime_dependencies(answer = [])
@@ -879,21 +1021,26 @@ module Puma
879
1021
  # If you do not specify a tag, Puma will infer it. If you do not want Puma
880
1022
  # to add a tag, use an empty string.
881
1023
  #
1024
+ # The default is the current file or directory base name.
1025
+ #
882
1026
  # @example
883
1027
  # tag 'app name'
884
1028
  # @example
885
1029
  # tag ''
1030
+ #
886
1031
  def tag(string)
887
1032
  @options[:tag] = string.to_s
888
1033
  end
889
1034
 
890
1035
  # Change the default interval for checking workers.
891
1036
  #
892
- # The default value is 5 seconds.
1037
+ # The default is 5 seconds.
893
1038
  #
894
1039
  # @note Cluster mode only.
1040
+ #
895
1041
  # @example
896
- # worker_check_interval 5
1042
+ # worker_check_interval 10
1043
+ #
897
1044
  # @see Puma::Cluster#check_workers
898
1045
  #
899
1046
  def worker_check_interval(interval)
@@ -906,11 +1053,14 @@ module Puma
906
1053
  # Setting this value will not protect against slow requests.
907
1054
  #
908
1055
  # This value must be greater than worker_check_interval.
909
- # The default value is 60 seconds.
1056
+ #
1057
+ # The default is 60 seconds.
910
1058
  #
911
1059
  # @note Cluster mode only.
1060
+ #
912
1061
  # @example
913
1062
  # worker_timeout 60
1063
+ #
914
1064
  # @see Puma::Cluster::Worker#ping_timeout
915
1065
  #
916
1066
  def worker_timeout(timeout)
@@ -926,12 +1076,13 @@ module Puma
926
1076
 
927
1077
  # Change the default worker timeout for booting.
928
1078
  #
929
- # If unspecified, this defaults to the value of worker_timeout.
1079
+ # The default is the value of `worker_timeout`.
930
1080
  #
931
1081
  # @note Cluster mode only.
932
1082
  #
933
1083
  # @example
934
1084
  # worker_boot_timeout 60
1085
+ #
935
1086
  # @see Puma::Cluster::Worker#ping_timeout
936
1087
  #
937
1088
  def worker_boot_timeout(timeout)
@@ -940,7 +1091,13 @@ module Puma
940
1091
 
941
1092
  # Set the timeout for worker shutdown.
942
1093
  #
1094
+ # The default is 60 seconds.
1095
+ #
943
1096
  # @note Cluster mode only.
1097
+ #
1098
+ # @example
1099
+ # worker_shutdown_timeout 90
1100
+ #
944
1101
  # @see Puma::Cluster::Worker#term
945
1102
  #
946
1103
  def worker_shutdown_timeout(timeout)
@@ -956,9 +1113,13 @@ module Puma
956
1113
  # 2. **:oldest** - the oldest workers (i.e. the workers that were started
957
1114
  # the longest time ago) will be culled.
958
1115
  #
1116
+ # The default is +:youngest+.
1117
+ #
959
1118
  # @note Cluster mode only.
1119
+ #
960
1120
  # @example
961
1121
  # worker_culling_strategy :oldest
1122
+ #
962
1123
  # @see Puma::Cluster#cull_workers
963
1124
  #
964
1125
  def worker_culling_strategy(strategy)
@@ -971,7 +1132,7 @@ module Puma
971
1132
  @options[:worker_culling_strategy] = strategy
972
1133
  end
973
1134
 
974
- # When set to true (the default), workers accept all requests
1135
+ # When set to true, workers accept all requests
975
1136
  # and queue them before passing them to the handlers.
976
1137
  # When set to false, each worker process accepts exactly as
977
1138
  # many requests as it is configured to simultaneously handle.
@@ -984,7 +1145,11 @@ module Puma
984
1145
  # slow clients will occupy a handler thread while the request
985
1146
  # is being sent. A reverse proxy, such as nginx, can handle
986
1147
  # slow clients and queue requests before they reach Puma.
1148
+ #
1149
+ # The default is +true+.
1150
+ #
987
1151
  # @see Puma::Server
1152
+ #
988
1153
  def queue_requests(answer=true)
989
1154
  @options[:queue_requests] = answer
990
1155
  end
@@ -1002,9 +1167,13 @@ module Puma
1002
1167
  # listening on the socket, allowing workers which are not processing any
1003
1168
  # requests to pick up new requests first.
1004
1169
  #
1170
+ # The default is 0.005 seconds.
1171
+ #
1005
1172
  # Only works on MRI. For all other interpreters, this setting does nothing.
1173
+ #
1006
1174
  # @see Puma::Server#handle_servers
1007
1175
  # @see Puma::ThreadPool#wait_for_less_busy_worker
1176
+ #
1008
1177
  # @version 5.0.0
1009
1178
  #
1010
1179
  def wait_for_less_busy_worker(val=0.005)
@@ -1018,7 +1187,7 @@ module Puma
1018
1187
  #
1019
1188
  # There are 5 possible values:
1020
1189
  #
1021
- # 1. **:socket** (the default) - read the peername from the socket using the
1190
+ # 1. **:socket** - read the peername from the socket using the
1022
1191
  # syscall. This is the normal behavior. If this fails for any reason (e.g.,
1023
1192
  # if the peer disconnects between the connection being accepted and the getpeername
1024
1193
  # system call), Puma will return "0.0.0.0"
@@ -1036,6 +1205,11 @@ module Puma
1036
1205
  # you wish. Because Puma never uses this field anyway, it's format is
1037
1206
  # entirely in your hands.
1038
1207
  #
1208
+ # The default is +:socket+.
1209
+ #
1210
+ # @example
1211
+ # set_remote_address :localhost
1212
+ #
1039
1213
  def set_remote_address(val=:socket)
1040
1214
  case val
1041
1215
  when :socket
@@ -1076,6 +1250,7 @@ module Puma
1076
1250
  # (default 1000), or pass 0 to disable auto refork.
1077
1251
  #
1078
1252
  # @note Cluster mode only.
1253
+ #
1079
1254
  # @version 5.0.0
1080
1255
  #
1081
1256
  def fork_worker(after_requests=1000)
@@ -1085,10 +1260,41 @@ module Puma
1085
1260
  # The number of requests to attempt inline before sending a client back to
1086
1261
  # the reactor to be subject to normal ordering.
1087
1262
  #
1263
+ # The default is 10.
1264
+ #
1265
+ # @example
1266
+ # max_fast_inline 20
1267
+ #
1088
1268
  def max_fast_inline(num_of_requests)
1089
1269
  @options[:max_fast_inline] = Float(num_of_requests)
1090
1270
  end
1091
1271
 
1272
+ # When `true`, keep-alive connections are maintained on inbound requests.
1273
+ # Enabling this setting reduces the number of TCP operations, reducing response
1274
+ # times for connections that can send multiple requests in a single connection.
1275
+ #
1276
+ # When Puma receives more incoming connections than available Puma threads,
1277
+ # enabling the keep-alive behavior may result in processing requests out-of-order,
1278
+ # increasing overall response time variance. Increased response time variance
1279
+ # means that the overall average of response times might not change, but more
1280
+ # outliers will exist. Those long-tail outliers may significantly affect response
1281
+ # times for some processed requests.
1282
+ #
1283
+ # When `false`, Puma closes the connection after each request, requiring the
1284
+ # client to open a new request. Disabling this setting guarantees that requests
1285
+ # will be processed in the order they are fully received, decreasing response
1286
+ # variance and eliminating long-tail outliers caused by keep-alive behavior.
1287
+ # The trade-off is that the number of TCP operations required will increase.
1288
+ #
1289
+ # The default is +true+.
1290
+ #
1291
+ # @example
1292
+ # enable_keep_alives false
1293
+ #
1294
+ def enable_keep_alives(enabled=true)
1295
+ @options[:enable_keep_alives] = enabled
1296
+ end
1297
+
1092
1298
  # Specify the backend for the IO selector.
1093
1299
  #
1094
1300
  # Provided values will be passed directly to +NIO::Selector.new+, with the
@@ -1108,6 +1314,14 @@ module Puma
1108
1314
  @options[:io_selector_backend] = backend.to_sym
1109
1315
  end
1110
1316
 
1317
+ # Ensures +STDOUT+ and +STDERR+ is immediately flushed to the underlying
1318
+ # operating system and is not buffered internally
1319
+ #
1320
+ # The default is +true+.
1321
+ #
1322
+ # @example
1323
+ # mutate_stdout_and_stderr_to_sync_on_write false
1324
+ #
1111
1325
  def mutate_stdout_and_stderr_to_sync_on_write(enabled=true)
1112
1326
  @options[:mutate_stdout_and_stderr_to_sync_on_write] = enabled
1113
1327
  end
@@ -1119,8 +1333,12 @@ module Puma
1119
1333
  #
1120
1334
  # When no Content-Length http header is present, it is compared against the
1121
1335
  # size of the body of the request.
1122
- #
1123
- # The default value for http_content_length_limit is nil.
1336
+ #
1337
+ # The default is +nil+.
1338
+ #
1339
+ # @example
1340
+ # http_content_length_limit 2_000_000_000
1341
+ #
1124
1342
  def http_content_length_limit(limit)
1125
1343
  @options[:http_content_length_limit] = limit
1126
1344
  end
@@ -1161,6 +1379,7 @@ module Puma
1161
1379
 
1162
1380
  # To avoid adding cert_pem and key_pem as URI params, we store them on the
1163
1381
  # options[:store] from where Puma binder knows how to find and extract them.
1382
+ #
1164
1383
  def add_pem_values_to_options_store(opts)
1165
1384
  return if defined?(JRUBY_VERSION)
1166
1385