puma 6.6.0 → 7.0.3

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
@@ -13,7 +13,7 @@ module Puma
13
13
  # config = Configuration.new({}) do |user_config|
14
14
  # user_config.port 3001
15
15
  # end
16
- # config.load
16
+ # config.clamp
17
17
  #
18
18
  # puts config.options[:binds] # => "tcp://127.0.0.1:3001"
19
19
  #
@@ -25,7 +25,7 @@ module Puma
25
25
  # Resulting configuration:
26
26
  #
27
27
  # config = Configuration.new(config_file: "puma_config.rb")
28
- # config.load
28
+ # config.clamp
29
29
  #
30
30
  # puts config.options[:binds] # => "tcp://127.0.0.1:3002"
31
31
  #
@@ -43,11 +43,11 @@ module Puma
43
43
  #
44
44
  # The following hooks have been updated:
45
45
  #
46
- # | DSL Method | Options Key | Fork Block Location |
47
- # | on_worker_boot | :before_worker_boot | inside, before |
48
- # | on_worker_shutdown | :before_worker_shutdown | inside, after |
49
- # | on_refork | :before_refork | inside |
50
- # | after_refork | :after_refork | inside |
46
+ # | DSL Method | Options Key | Fork Block Location |
47
+ # | before_worker_boot | :before_worker_boot | inside, before |
48
+ # | before_worker_shutdown | :before_worker_shutdown | inside, after |
49
+ # | before_refork | :before_refork | inside |
50
+ # | after_refork | :after_refork | inside |
51
51
  #
52
52
  class DSL
53
53
  ON_WORKER_KEY = [String, Symbol].freeze
@@ -370,18 +370,21 @@ module Puma
370
370
  @options[:idle_timeout] = Integer(seconds)
371
371
  end
372
372
 
373
- # Work around leaky apps that leave garbage in Thread locals
374
- # across requests.
373
+ # Use a clean fiber per request which ensures a clean slate for fiber
374
+ # locals and fiber storage. Also provides a cleaner backtrace with less
375
+ # Puma internal stack frames.
375
376
  #
376
377
  # The default is +false+.
377
378
  #
378
379
  # @example
379
- # clean_thread_locals
380
+ # fiber_per_request
380
381
  #
381
- def clean_thread_locals(which=true)
382
- @options[:clean_thread_locals] = which
382
+ def fiber_per_request(which=true)
383
+ @options[:fiber_per_request] = which
383
384
  end
384
385
 
386
+ alias clean_thread_locals fiber_per_request
387
+
385
388
  # When shutting down, drain the accept socket of pending connections and
386
389
  # process them. This loops over the accept socket until there are no more
387
390
  # read events and then stops looking and waits for the requests to finish.
@@ -434,14 +437,18 @@ module Puma
434
437
  # This can be called multiple times to add code each time.
435
438
  #
436
439
  # @example
437
- # on_restart do
440
+ # before_restart do
438
441
  # puts 'On restart...'
439
442
  # end
440
443
  #
441
- def on_restart(&block)
442
- process_hook :on_restart, nil, block, 'on_restart'
444
+ def before_restart(&block)
445
+ Puma.deprecate_method_change :on_restart, __callee__, __method__
446
+
447
+ process_hook :before_restart, nil, block
443
448
  end
444
449
 
450
+ alias_method :on_restart, :before_restart
451
+
445
452
  # Command to use to restart Puma. This should be just how to
446
453
  # load Puma itself (ie. 'ruby -Ilib bin/puma'), not the arguments
447
454
  # to Puma, as those are the same as the original process.
@@ -654,8 +661,6 @@ module Puma
654
661
  # @example
655
662
  # state_permission 0600
656
663
  #
657
- # @version 5.0.0
658
- #
659
664
  def state_permission(permission)
660
665
  @options[:state_permission] = permission
661
666
  end
@@ -729,9 +734,7 @@ module Puma
729
734
  # end
730
735
  #
731
736
  def before_fork(&block)
732
- warn_if_in_single_mode('before_fork')
733
-
734
- process_hook :before_fork, nil, block, 'before_fork'
737
+ process_hook :before_fork, nil, block, cluster_only: true
735
738
  end
736
739
 
737
740
  # Code to run in a worker when it boots to setup
@@ -742,16 +745,18 @@ module Puma
742
745
  # @note Cluster mode only.
743
746
  #
744
747
  # @example
745
- # on_worker_boot do
748
+ # before_worker_boot do
746
749
  # puts 'Before worker boot...'
747
750
  # end
748
751
  #
749
- def on_worker_boot(key = nil, &block)
750
- warn_if_in_single_mode('on_worker_boot')
752
+ def before_worker_boot(key = nil, &block)
753
+ Puma.deprecate_method_change :on_worker_boot, __callee__, __method__
751
754
 
752
- process_hook :before_worker_boot, key, block, 'on_worker_boot'
755
+ process_hook :before_worker_boot, key, block, cluster_only: true
753
756
  end
754
757
 
758
+ alias_method :on_worker_boot, :before_worker_boot
759
+
755
760
  # Code to run immediately before a worker shuts
756
761
  # down (after it has finished processing HTTP requests). The worker's
757
762
  # index is passed as an argument. These hooks
@@ -763,16 +768,18 @@ module Puma
763
768
  # @note Cluster mode only.
764
769
  #
765
770
  # @example
766
- # on_worker_shutdown do
771
+ # before_worker_shutdown do
767
772
  # puts 'On worker shutdown...'
768
773
  # end
769
774
  #
770
- def on_worker_shutdown(key = nil, &block)
771
- warn_if_in_single_mode('on_worker_shutdown')
775
+ def before_worker_shutdown(key = nil, &block)
776
+ Puma.deprecate_method_change :on_worker_shutdown, __callee__, __method__
772
777
 
773
- process_hook :before_worker_shutdown, key, block, 'on_worker_shutdown'
778
+ process_hook :before_worker_shutdown, key, block, cluster_only: true
774
779
  end
775
780
 
781
+ alias_method :on_worker_shutdown, :before_worker_shutdown
782
+
776
783
  # Code to run in the master right before a worker is started. The worker's
777
784
  # index is passed as an argument.
778
785
  #
@@ -781,16 +788,18 @@ module Puma
781
788
  # @note Cluster mode only.
782
789
  #
783
790
  # @example
784
- # on_worker_fork do
791
+ # before_worker_fork do
785
792
  # puts 'Before worker fork...'
786
793
  # end
787
794
  #
788
- def on_worker_fork(&block)
789
- warn_if_in_single_mode('on_worker_fork')
795
+ def before_worker_fork(&block)
796
+ Puma.deprecate_method_change :on_worker_fork, __callee__, __method__
790
797
 
791
- process_hook :before_worker_fork, nil, block, 'on_worker_fork'
798
+ process_hook :before_worker_fork, nil, block, cluster_only: true
792
799
  end
793
800
 
801
+ alias_method :on_worker_fork, :before_worker_fork
802
+
794
803
  # Code to run in the master after a worker has been started. The worker's
795
804
  # index is passed as an argument.
796
805
  #
@@ -804,34 +813,39 @@ module Puma
804
813
  # end
805
814
  #
806
815
  def after_worker_fork(&block)
807
- warn_if_in_single_mode('after_worker_fork')
808
-
809
- process_hook :after_worker_fork, nil, block, 'after_worker_fork'
816
+ process_hook :after_worker_fork, nil, block, cluster_only: true
810
817
  end
811
818
 
812
819
  alias_method :after_worker_boot, :after_worker_fork
813
820
 
814
- # Code to run after puma is booted (works for both: single and clustered)
821
+ # Code to run after puma is booted (works for both single and cluster modes).
815
822
  #
816
823
  # @example
817
- # on_booted do
824
+ # after_booted do
818
825
  # puts 'After booting...'
819
826
  # end
820
827
  #
821
- def on_booted(&block)
822
- @config.options[:events].on_booted(&block)
828
+ def after_booted(&block)
829
+ Puma.deprecate_method_change :on_booted, __callee__, __method__
830
+
831
+ @config.events.after_booted(&block)
823
832
  end
824
833
 
834
+ alias_method :on_booted, :after_booted
835
+
825
836
  # Code to run after puma is stopped (works for both: single and clustered)
826
837
  #
827
838
  # @example
828
- # on_stopped do
839
+ # after_stopped do
829
840
  # puts 'After stopping...'
830
841
  # end
831
842
  #
832
- def on_stopped(&block)
833
- @config.options[:events].on_stopped(&block)
843
+ def after_stopped(&block)
844
+ Puma.deprecate_method_change :on_stopped, __callee__, __method__
845
+
846
+ @config.events.after_stopped(&block)
834
847
  end
848
+ alias_method :on_stopped, :after_stopped
835
849
 
836
850
  # When `fork_worker` is enabled, code to run in Worker 0
837
851
  # before all other workers are re-forked from this process,
@@ -847,25 +861,27 @@ module Puma
847
861
  # @note Cluster mode with `fork_worker` enabled only.
848
862
  #
849
863
  # @example
850
- # on_refork do
864
+ # before_refork do
851
865
  # 3.times {GC.start}
852
866
  # end
853
867
  #
854
868
  # @version 5.0.0
855
869
  #
856
- def on_refork(key = nil, &block)
857
- warn_if_in_single_mode('on_refork')
870
+ def before_refork(key = nil, &block)
871
+ Puma.deprecate_method_change :on_refork, __callee__, __method__
858
872
 
859
- process_hook :before_refork, key, block, 'on_refork'
873
+ process_hook :before_refork, key, block, cluster_only: true
860
874
  end
861
875
 
876
+ alias_method :on_refork, :before_refork
877
+
862
878
  # When `fork_worker` is enabled, code to run in Worker 0
863
879
  # after all other workers are re-forked from this process,
864
880
  # after the server has temporarily stopped serving requests
865
881
  # (once per complete refork cycle).
866
882
  #
867
883
  # This can be used to re-open any connections to remote servers
868
- # (database, Redis, ...) that were closed via on_refork.
884
+ # (database, Redis, ...) that were closed via before_refork.
869
885
  #
870
886
  # This can be called multiple times to add several hooks.
871
887
  #
@@ -877,7 +893,7 @@ module Puma
877
893
  # end
878
894
  #
879
895
  def after_refork(key = nil, &block)
880
- process_hook :after_refork, key, block, 'after_refork'
896
+ process_hook :after_refork, key, block
881
897
  end
882
898
 
883
899
  # Provide a block to be executed just before a thread is added to the thread
@@ -893,14 +909,18 @@ module Puma
893
909
  # This can be called multiple times to add several hooks.
894
910
  #
895
911
  # @example
896
- # on_thread_start do
912
+ # before_thread_start do
897
913
  # puts 'On thread start...'
898
914
  # end
899
915
  #
900
- def on_thread_start(&block)
901
- process_hook :before_thread_start, nil, block, 'on_thread_start'
916
+ def before_thread_start(&block)
917
+ Puma.deprecate_method_change :on_thread_start, __callee__, __method__
918
+
919
+ process_hook :before_thread_start, nil, block
902
920
  end
903
921
 
922
+ alias_method :on_thread_start, :before_thread_start
923
+
904
924
  # Provide a block to be executed after a thread is trimmed from the thread
905
925
  # pool. Be careful: while this block executes, Puma's main loop is
906
926
  # blocked, so no new requests will be picked up.
@@ -917,14 +937,18 @@ module Puma
917
937
  # This can be called multiple times to add several hooks.
918
938
  #
919
939
  # @example
920
- # on_thread_exit do
940
+ # before_thread_exit do
921
941
  # puts 'On thread exit...'
922
942
  # end
923
943
  #
924
- def on_thread_exit(&block)
925
- process_hook :before_thread_exit, nil, block, 'on_thread_exit'
944
+ def before_thread_exit(&block)
945
+ Puma.deprecate_method_change :on_thread_exit, __callee__, __method__
946
+
947
+ process_hook :before_thread_exit, nil, block
926
948
  end
927
949
 
950
+ alias_method :on_thread_exit, :before_thread_exit
951
+
928
952
  # Code to run out-of-band when the worker is idle.
929
953
  # These hooks run immediately after a request has finished
930
954
  # processing and there are no busy threads on the worker.
@@ -936,7 +960,7 @@ module Puma
936
960
  # This can be called multiple times to add several hooks.
937
961
  #
938
962
  def out_of_band(&block)
939
- process_hook :out_of_band, nil, block, 'out_of_band'
963
+ process_hook :out_of_band, nil, block
940
964
  end
941
965
 
942
966
  # The directory to operate out of.
@@ -950,8 +974,8 @@ module Puma
950
974
  @options[:directory] = dir.to_s
951
975
  end
952
976
 
953
- # Preload the application before starting the workers; this conflicts with
954
- # phased restart feature.
977
+ # Preload the application before forking the workers; this conflicts with
978
+ # the phased restart feature.
955
979
  #
956
980
  # The default is +true+ if your app uses more than 1 worker.
957
981
  #
@@ -1111,7 +1135,7 @@ module Puma
1111
1135
 
1112
1136
  # Set the timeout for worker shutdown.
1113
1137
  #
1114
- # The default is 60 seconds.
1138
+ # The default is 30 seconds.
1115
1139
  #
1116
1140
  # @note Cluster mode only.
1117
1141
  #
@@ -1143,10 +1167,10 @@ module Puma
1143
1167
  # @see Puma::Cluster#cull_workers
1144
1168
  #
1145
1169
  def worker_culling_strategy(strategy)
1146
- stategy = strategy.to_sym
1170
+ strategy = strategy.to_sym
1147
1171
 
1148
1172
  if ![:youngest, :oldest].include?(strategy)
1149
- raise "Invalid value for worker_culling_strategy - #{stategy}"
1173
+ raise "Invalid value for worker_culling_strategy - #{strategy}"
1150
1174
  end
1151
1175
 
1152
1176
  @options[:worker_culling_strategy] = strategy
@@ -1194,8 +1218,6 @@ module Puma
1194
1218
  # @see Puma::Server#handle_servers
1195
1219
  # @see Puma::ThreadPool#wait_for_less_busy_worker
1196
1220
  #
1197
- # @version 5.0.0
1198
- #
1199
1221
  def wait_for_less_busy_worker(val=0.005)
1200
1222
  @options[:wait_for_less_busy_worker] = val.to_f
1201
1223
  end
@@ -1269,24 +1291,31 @@ module Puma
1269
1291
  # A refork will automatically trigger once after the specified number of requests
1270
1292
  # (default 1000), or pass 0 to disable auto refork.
1271
1293
  #
1294
+ # @note This is experimental.
1272
1295
  # @note Cluster mode only.
1273
1296
  #
1274
- # @version 5.0.0
1275
- #
1276
1297
  def fork_worker(after_requests=1000)
1277
1298
  @options[:fork_worker] = Integer(after_requests)
1278
1299
  end
1279
1300
 
1280
- # The number of requests to attempt inline before sending a client back to
1281
- # the reactor to be subject to normal ordering.
1301
+ # @deprecated Use {#max_keep_alive} instead.
1282
1302
  #
1283
- # The default is 10.
1303
+ def max_fast_inline(num_of_requests)
1304
+ Puma.deprecate_method_change :max_fast_inline, __method__, :max_keep_alive
1305
+ @options[:max_keep_alive] ||= Float(num_of_requests) unless num_of_requests.nil?
1306
+ end
1307
+
1308
+ # The number of requests a keep-alive client can submit before being closed.
1309
+ # Note that some applications (server to server) may benefit from a very high
1310
+ # number or Float::INFINITY.
1311
+ #
1312
+ # The default is 999.
1284
1313
  #
1285
1314
  # @example
1286
- # max_fast_inline 20
1315
+ # max_keep_alive 20
1287
1316
  #
1288
- def max_fast_inline(num_of_requests)
1289
- @options[:max_fast_inline] = Float(num_of_requests)
1317
+ def max_keep_alive(num_of_requests)
1318
+ @options[:max_keep_alive] = Float(num_of_requests) unless num_of_requests.nil?
1290
1319
  end
1291
1320
 
1292
1321
  # When `true`, keep-alive connections are maintained on inbound requests.
@@ -1416,30 +1445,21 @@ module Puma
1416
1445
  end
1417
1446
  end
1418
1447
 
1419
- def process_hook(options_key, key, block, meth)
1448
+ def process_hook(options_key, key, block, cluster_only: false)
1449
+ raise ArgumentError, "expected #{options_key} to be given a block" unless block
1450
+
1451
+ @config.hooks[options_key] = true
1452
+
1420
1453
  @options[options_key] ||= []
1421
- if ON_WORKER_KEY.include? key.class
1422
- @options[options_key] << [block, key.to_sym]
1454
+ hook_options = { block: block, cluster_only: cluster_only }
1455
+ hook_options[:id] = if ON_WORKER_KEY.include?(key.class)
1456
+ key.to_sym
1423
1457
  elsif key.nil?
1424
- @options[options_key] << block
1458
+ nil
1425
1459
  else
1426
- raise "'#{meth}' key must be String or Symbol"
1427
- end
1428
- end
1429
-
1430
- def warn_if_in_single_mode(hook_name)
1431
- return if @options[:silence_fork_callback_warning]
1432
- # user_options (CLI) have precedence over config file
1433
- workers_val = @config.options.user_options[:workers] || @options[:workers] ||
1434
- @config.puma_default_options[:workers] || 0
1435
- if workers_val == 0
1436
- log_string =
1437
- "Warning: You specified code to run in a `#{hook_name}` block, " \
1438
- "but Puma is not configured to run in cluster mode (worker count > 0), " \
1439
- "so your `#{hook_name}` block will not run."
1440
-
1441
- LogWriter.stdio.log(log_string)
1460
+ raise "'#{options_key}' key must be String or Symbol"
1442
1461
  end
1462
+ @options[options_key] << hook_options
1443
1463
  end
1444
1464
  end
1445
1465
  end
@@ -78,10 +78,12 @@ module Puma
78
78
  def request_title(req)
79
79
  env = req.env
80
80
 
81
+ query_string = env[QUERY_STRING]
82
+
81
83
  REQUEST_FORMAT % [
82
84
  env[REQUEST_METHOD],
83
85
  env[REQUEST_PATH] || env[PATH_INFO],
84
- env[QUERY_STRING] || "",
86
+ query_string.nil? || query_string.empty? ? "" : "?#{query_string}",
85
87
  env[HTTP_X_FORWARDED_FOR] || env[REMOTE_ADDR] || "-"
86
88
  ]
87
89
  end
data/lib/puma/events.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Puma
4
4
 
5
5
  # This is an event sink used by `Puma::Server` to handle
6
- # lifecycle events such as :on_booted, :on_restart, and :on_stopped.
6
+ # lifecycle events such as :after_booted, :before_restart, and :after_stopped.
7
7
  # Using `Puma::DSL` it is possible to register callback hooks
8
8
  # for each event type.
9
9
  class Events
@@ -30,28 +30,43 @@ module Puma
30
30
  h
31
31
  end
32
32
 
33
+ def after_booted(&block)
34
+ register(:after_booted, &block)
35
+ end
36
+
37
+ def before_restart(&block)
38
+ register(:before_restart, &block)
39
+ end
40
+
41
+ def after_stopped(&block)
42
+ register(:after_stopped, &block)
43
+ end
44
+
33
45
  def on_booted(&block)
34
- register(:on_booted, &block)
46
+ Puma.deprecate_method_change :on_booted, __callee__, :after_booted
47
+ after_booted(&block)
35
48
  end
36
49
 
37
50
  def on_restart(&block)
38
- register(:on_restart, &block)
51
+ Puma.deprecate_method_change :on_restart, __callee__, :before_restart
52
+ before_restart(&block)
39
53
  end
40
54
 
41
55
  def on_stopped(&block)
42
- register(:on_stopped, &block)
56
+ Puma.deprecate_method_change :on_stopped, __callee__, :after_stopped
57
+ after_stopped(&block)
43
58
  end
44
59
 
45
- def fire_on_booted!
46
- fire(:on_booted)
60
+ def fire_after_booted!
61
+ fire(:after_booted)
47
62
  end
48
63
 
49
- def fire_on_restart!
50
- fire(:on_restart)
64
+ def fire_before_restart!
65
+ fire(:before_restart)
51
66
  end
52
67
 
53
- def fire_on_stopped!
54
- fire(:on_stopped)
68
+ def fire_after_stopped!
69
+ fire(:after_stopped)
55
70
  end
56
71
  end
57
72
  end
@@ -34,13 +34,17 @@ module Puma
34
34
 
35
35
  alias_method :clear, :reset
36
36
 
37
- # before Ruby 2.5, `write` would only take one argument
38
- if RUBY_VERSION >= '2.5' && RUBY_ENGINE != 'truffleruby'
39
- alias_method :append, :write
40
- else
37
+ # Create an `IoBuffer#append` method that accepts multiple strings and writes them
38
+ if RUBY_ENGINE == 'truffleruby'
39
+ # truffleruby (24.2.1, like ruby 3.3.7)
40
+ # StringIO.new.write("a", "b") # => `write': wrong number of arguments (given 2, expected 1) (ArgumentError)
41
41
  def append(*strs)
42
42
  strs.each { |str| write str }
43
43
  end
44
+ else
45
+ # Ruby 3+
46
+ # StringIO.new.write("a", "b") # => 2
47
+ alias_method :append, :write
44
48
  end
45
49
  end
46
50
  end
@@ -37,7 +37,7 @@ module Puma
37
37
  ENV['PUMA_BUNDLER_PRUNED'] = '1'
38
38
  ENV["BUNDLE_APP_CONFIG"] = bundle_app_config
39
39
  args = [Gem.ruby, puma_wild_path, '-I', dirs.join(':')] + @original_argv
40
- # Ruby 2.0+ defaults to true which breaks socket activation
40
+ # Defaults to true which breaks socket activation
41
41
  args += [{:close_others => false}]
42
42
  Kernel.exec(*args)
43
43
  end
data/lib/puma/launcher.rb CHANGED
@@ -22,12 +22,15 @@ module Puma
22
22
  #
23
23
  # +conf+ A Puma::Configuration object indicating how to run the server.
24
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.
25
+ # +launcher_args+ A Hash that has a few optional keys.
26
+ # - +:log_writer+:: Expected to hold an object similar to `Puma::LogWriter.stdio`.
27
+ # This object will be responsible for broadcasting Puma's internal state
28
+ # to a logging destination.
29
+ # - +:events+:: Expected to hold an object similar to `Puma::Events`.
30
+ # - +:argv+:: Expected to be an array of strings.
31
+ # - +:env+:: Expected to hold a hash of environment variables.
32
+ #
33
+ # These arguments are re-used when restarting the puma server.
31
34
  #
32
35
  # Examples:
33
36
  #
@@ -48,18 +51,21 @@ module Puma
48
51
 
49
52
  env = launcher_args.delete(:env) || ENV
50
53
 
51
- @config.options[:log_writer] = @log_writer
54
+ @config.clamp
55
+ @options = @config.options
56
+
57
+ @options[:log_writer] = @log_writer
58
+ @options[:logger] = @log_writer if clustered?
52
59
 
53
60
  # Advertise the Configuration
54
61
  Puma.cli_config = @config if defined?(Puma.cli_config)
62
+ log_config if env['PUMA_LOG_CONFIG']
55
63
 
56
- @config.load
57
-
58
- @binder = Binder.new(@log_writer, conf)
59
- @binder.create_inherited_fds(ENV).each { |k| ENV.delete k }
60
- @binder.create_activated_fds(ENV).each { |k| ENV.delete k }
64
+ @binder = Binder.new(@log_writer, @options)
65
+ @binder.create_inherited_fds(env).each { |k| env.delete k }
66
+ @binder.create_activated_fds(env).each { |k| env.delete k }
61
67
 
62
- @environment = conf.environment
68
+ @environment = @config.environment
63
69
 
64
70
  # Load the systemd integration if we detect systemd's NOTIFY_SOCKET.
65
71
  # Skip this on JRuby though, because it is incompatible with the systemd
@@ -68,20 +74,17 @@ module Puma
68
74
  @config.plugins.create('systemd')
69
75
  end
70
76
 
71
- if @config.options[:bind_to_activated_sockets]
72
- @config.options[:binds] = @binder.synthesize_binds_from_activated_fs(
73
- @config.options[:binds],
74
- @config.options[:bind_to_activated_sockets] == 'only'
77
+ if @options[:bind_to_activated_sockets]
78
+ @options[:binds] = @binder.synthesize_binds_from_activated_fs(
79
+ @options[:binds],
80
+ @options[:bind_to_activated_sockets] == 'only'
75
81
  )
76
82
  end
77
83
 
78
- @options = @config.options
79
- @config.clamp
80
-
81
84
  @log_writer.formatter = LogWriter::PidFormatter.new if clustered?
82
- @log_writer.formatter = options[:log_formatter] if @options[:log_formatter]
85
+ @log_writer.formatter = @options[:log_formatter] if @options[:log_formatter]
83
86
 
84
- @log_writer.custom_logger = options[:custom_logger] if @options[:custom_logger]
87
+ @log_writer.custom_logger = @options[:custom_logger] if @options[:custom_logger]
85
88
 
86
89
  generate_restart_data
87
90
 
@@ -97,8 +100,6 @@ module Puma
97
100
  set_rack_environment
98
101
 
99
102
  if clustered?
100
- @options[:logger] = @log_writer
101
-
102
103
  @runner = Cluster.new(self)
103
104
  else
104
105
  @runner = Single.new(self)
@@ -106,8 +107,6 @@ module Puma
106
107
  Puma.stats_object = @runner
107
108
 
108
109
  @status = :run
109
-
110
- log_config if env['PUMA_LOG_CONFIG']
111
110
  end
112
111
 
113
112
  attr_reader :binder, :log_writer, :events, :config, :options, :restart_dir
@@ -277,7 +276,7 @@ module Puma
277
276
  end
278
277
 
279
278
  def do_graceful_stop
280
- @events.fire_on_stopped!
279
+ @events.fire_after_stopped!
281
280
  @runner.stop_blocked
282
281
  end
283
282
 
@@ -289,8 +288,8 @@ module Puma
289
288
  end
290
289
 
291
290
  def restart!
292
- @events.fire_on_restart!
293
- @config.run_hooks :on_restart, self, @log_writer
291
+ @events.fire_before_restart!
292
+ @config.run_hooks :before_restart, self, @log_writer
294
293
 
295
294
  if Puma.jruby?
296
295
  close_binder_listeners
data/lib/puma/minissl.rb CHANGED
@@ -172,7 +172,6 @@ module Puma
172
172
  end
173
173
  end
174
174
  rescue IOError, SystemCallError
175
- Puma::Util.purge_interrupt_queue
176
175
  # nothing
177
176
  ensure
178
177
  @socket.close
@@ -14,9 +14,9 @@ Puma::Plugin.create do
14
14
  launcher.log_writer.log "* Enabling systemd notification integration"
15
15
 
16
16
  # hook_events
17
- launcher.events.on_booted { Puma::SdNotify.ready }
18
- launcher.events.on_stopped { Puma::SdNotify.stopping }
19
- launcher.events.on_restart { Puma::SdNotify.reloading }
17
+ launcher.events.after_booted { Puma::SdNotify.ready }
18
+ launcher.events.after_stopped { Puma::SdNotify.stopping }
19
+ launcher.events.before_restart { Puma::SdNotify.reloading }
20
20
 
21
21
  # start watchdog
22
22
  if Puma::SdNotify.watchdog?