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/dsl.rb DELETED
@@ -1,1204 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'const'
4
- require_relative 'util'
5
-
6
- module Puma
7
- # The methods that are available for use inside the configuration file.
8
- # These same methods are used in Puma cli and the rack handler
9
- # internally.
10
- #
11
- # Used manually (via CLI class):
12
- #
13
- # config = Configuration.new({}) do |user_config|
14
- # user_config.port 3001
15
- # end
16
- # config.load
17
- #
18
- # puts config.options[:binds] # => "tcp://127.0.0.1:3001"
19
- #
20
- # Used to load file:
21
- #
22
- # $ cat puma_config.rb
23
- # port 3002
24
- #
25
- # Resulting configuration:
26
- #
27
- # config = Configuration.new(config_file: "puma_config.rb")
28
- # config.load
29
- #
30
- # puts config.options[:binds] # => "tcp://127.0.0.1:3002"
31
- #
32
- # You can also find many examples being used by the test suite in
33
- # +test/config+.
34
- #
35
- # Puma v6 adds the option to specify a key name (String or Symbol) to the
36
- # hooks that run inside the forked workers. All the hooks run inside the
37
- # {Puma::Cluster::Worker#run} method.
38
- #
39
- # Previously, the worker index and the LogWriter instance were passed to the
40
- # hook blocks/procs. If a key name is specified, a hash is passed as the last
41
- # parameter. This allows storage of data, typically objects that are created
42
- # before the worker that need to be passed to the hook when the worker is shutdown.
43
- #
44
- # The following hooks have been updated:
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
- #
51
- class DSL
52
- ON_WORKER_KEY = [String, Symbol].freeze
53
-
54
- # convenience method so logic can be used in CI
55
- # @see ssl_bind
56
- #
57
- def self.ssl_bind_str(host, port, opts)
58
- verify = opts.fetch(:verify_mode, 'none').to_s
59
-
60
- tls_str =
61
- if opts[:no_tlsv1_1] then '&no_tlsv1_1=true'
62
- elsif opts[:no_tlsv1] then '&no_tlsv1=true'
63
- else ''
64
- end
65
-
66
- ca_additions = "&ca=#{Puma::Util.escape(opts[:ca])}" if ['peer', 'force_peer'].include?(verify)
67
-
68
- low_latency_str = opts.key?(:low_latency) ? "&low_latency=#{opts[:low_latency]}" : ''
69
- backlog_str = opts[:backlog] ? "&backlog=#{Integer(opts[:backlog])}" : ''
70
-
71
- if defined?(JRUBY_VERSION)
72
- cipher_suites = opts[:ssl_cipher_list] ? "&ssl_cipher_list=#{opts[:ssl_cipher_list]}" : nil # old name
73
- cipher_suites = "#{cipher_suites}&cipher_suites=#{opts[:cipher_suites]}" if opts[:cipher_suites]
74
- protocols = opts[:protocols] ? "&protocols=#{opts[:protocols]}" : nil
75
-
76
- keystore_additions = "keystore=#{opts[:keystore]}&keystore-pass=#{opts[:keystore_pass]}"
77
- keystore_additions = "#{keystore_additions}&keystore-type=#{opts[:keystore_type]}" if opts[:keystore_type]
78
- if opts[:truststore]
79
- truststore_additions = "&truststore=#{opts[:truststore]}"
80
- truststore_additions = "#{truststore_additions}&truststore-pass=#{opts[:truststore_pass]}" if opts[:truststore_pass]
81
- truststore_additions = "#{truststore_additions}&truststore-type=#{opts[:truststore_type]}" if opts[:truststore_type]
82
- end
83
-
84
- "ssl://#{host}:#{port}?#{keystore_additions}#{truststore_additions}#{cipher_suites}#{protocols}" \
85
- "&verify_mode=#{verify}#{tls_str}#{ca_additions}#{backlog_str}"
86
- else
87
- ssl_cipher_filter = opts[:ssl_cipher_filter] ? "&ssl_cipher_filter=#{opts[:ssl_cipher_filter]}" : nil
88
- v_flags = (ary = opts[:verification_flags]) ? "&verification_flags=#{Array(ary).join ','}" : nil
89
-
90
- cert_flags = (cert = opts[:cert]) ? "cert=#{Puma::Util.escape(cert)}" : nil
91
- key_flags = (key = opts[:key]) ? "&key=#{Puma::Util.escape(key)}" : nil
92
- password_flags = (password_command = opts[:key_password_command]) ? "&key_password_command=#{Puma::Util.escape(password_command)}" : nil
93
-
94
- reuse_flag =
95
- if (reuse = opts[:reuse])
96
- if reuse == true
97
- '&reuse=dflt'
98
- elsif reuse.is_a?(Hash) && (reuse.key?(:size) || reuse.key?(:timeout))
99
- val = +''
100
- if (size = reuse[:size]) && Integer === size
101
- val << size.to_s
102
- end
103
- if (timeout = reuse[:timeout]) && Integer === timeout
104
- val << ",#{timeout}"
105
- end
106
- if val.empty?
107
- nil
108
- else
109
- "&reuse=#{val}"
110
- end
111
- else
112
- nil
113
- end
114
- else
115
- nil
116
- end
117
-
118
- "ssl://#{host}:#{port}?#{cert_flags}#{key_flags}#{password_flags}#{ssl_cipher_filter}" \
119
- "#{reuse_flag}&verify_mode=#{verify}#{tls_str}#{ca_additions}#{v_flags}#{backlog_str}#{low_latency_str}"
120
- end
121
- end
122
-
123
- def initialize(options, config)
124
- @config = config
125
- @options = options
126
-
127
- @plugins = []
128
- end
129
-
130
- def _load_from(path)
131
- if path
132
- @path = path
133
- instance_eval(File.read(path), path, 1)
134
- end
135
- ensure
136
- _offer_plugins
137
- end
138
-
139
- def _offer_plugins
140
- @plugins.each do |o|
141
- if o.respond_to? :config
142
- @options.shift
143
- o.config self
144
- end
145
- end
146
-
147
- @plugins.clear
148
- end
149
-
150
- def set_default_host(host)
151
- @options[:default_host] = host
152
- end
153
-
154
- def default_host
155
- @options[:default_host] || Configuration::DEFAULTS[:tcp_host]
156
- end
157
-
158
- def inject(&blk)
159
- instance_eval(&blk)
160
- end
161
-
162
- def get(key,default=nil)
163
- @options[key.to_sym] || default
164
- end
165
-
166
- # Load the named plugin for use by this configuration
167
- #
168
- def plugin(name)
169
- @plugins << @config.load_plugin(name)
170
- end
171
-
172
- # Use an object or block as the rack application. This allows the
173
- # configuration file to be the application itself.
174
- #
175
- # @example
176
- # app do |env|
177
- # body = 'Hello, World!'
178
- #
179
- # [
180
- # 200,
181
- # {
182
- # 'Content-Type' => 'text/plain',
183
- # 'Content-Length' => body.length.to_s
184
- # },
185
- # [body]
186
- # ]
187
- # end
188
- #
189
- # @see Puma::Configuration#app
190
- #
191
- def app(obj=nil, &block)
192
- obj ||= block
193
-
194
- raise "Provide either a #call'able or a block" unless obj
195
-
196
- @options[:app] = obj
197
- end
198
-
199
- # Start the Puma control rack application on +url+. This application can
200
- # be communicated with to control the main server. Additionally, you can
201
- # provide an authentication token, so all requests to the control server
202
- # will need to include that token as a query parameter. This allows for
203
- # simple authentication.
204
- #
205
- # Check out {Puma::App::Status} to see what the app has available.
206
- #
207
- # @example
208
- # activate_control_app 'unix:///var/run/pumactl.sock'
209
- # @example
210
- # activate_control_app 'unix:///var/run/pumactl.sock', { auth_token: '12345' }
211
- # @example
212
- # activate_control_app 'unix:///var/run/pumactl.sock', { no_token: true }
213
- def activate_control_app(url="auto", opts={})
214
- if url == "auto"
215
- path = Configuration.temp_path
216
- @options[:control_url] = "unix://#{path}"
217
- @options[:control_url_temp] = path
218
- else
219
- @options[:control_url] = url
220
- end
221
-
222
- if opts[:no_token]
223
- # We need to use 'none' rather than :none because this value will be
224
- # passed on to an instance of OptionParser, which doesn't support
225
- # symbols as option values.
226
- #
227
- # See: https://github.com/puma/puma/issues/1193#issuecomment-305995488
228
- auth_token = 'none'
229
- else
230
- auth_token = opts[:auth_token]
231
- auth_token ||= Configuration.random_token
232
- end
233
-
234
- @options[:control_auth_token] = auth_token
235
- @options[:control_url_umask] = opts[:umask] if opts[:umask]
236
- end
237
-
238
- # Load additional configuration from a file
239
- # Files get loaded later via Configuration#load
240
- def load(file)
241
- @options[:config_files] ||= []
242
- @options[:config_files] << file
243
- end
244
-
245
- # Bind the server to +url+. "tcp://", "unix://" and "ssl://" are the only
246
- # accepted protocols. Multiple urls can be bound to, calling +bind+ does
247
- # not overwrite previous bindings.
248
- #
249
- # The default is "tcp://0.0.0.0:9292".
250
- #
251
- # You can use query parameters within the url to specify options:
252
- #
253
- # * Set the socket backlog depth with +backlog+, default is 1024.
254
- # * Set up an SSL certificate with +key+ & +cert+.
255
- # * Set up an SSL certificate for mTLS with +key+, +cert+, +ca+ and +verify_mode+.
256
- # * Set whether to optimize for low latency instead of throughput with
257
- # +low_latency+, default is to not optimize for low latency. This is done
258
- # via +Socket::TCP_NODELAY+.
259
- # * Set socket permissions with +umask+.
260
- #
261
- # @example Backlog depth
262
- # bind 'unix:///var/run/puma.sock?backlog=512'
263
- # @example SSL cert
264
- # bind 'ssl://127.0.0.1:9292?key=key.key&cert=cert.pem'
265
- # @example SSL cert for mutual TLS (mTLS)
266
- # bind 'ssl://127.0.0.1:9292?key=key.key&cert=cert.pem&ca=ca.pem&verify_mode=force_peer'
267
- # @example Disable optimization for low latency
268
- # bind 'tcp://0.0.0.0:9292?low_latency=false'
269
- # @example Socket permissions
270
- # bind 'unix:///var/run/puma.sock?umask=0111'
271
- # @see Puma::Runner#load_and_bind
272
- # @see Puma::Cluster#run
273
- #
274
- def bind(url)
275
- @options[:binds] ||= []
276
- @options[:binds] << url
277
- end
278
-
279
- def clear_binds!
280
- @options[:binds] = []
281
- end
282
-
283
- # Bind to (systemd) activated sockets, regardless of configured binds.
284
- #
285
- # Systemd can present sockets as file descriptors that are already opened.
286
- # By default Puma will use these but only if it was explicitly told to bind
287
- # to the socket. If not, it will close the activated sockets. This means
288
- # all configuration is duplicated.
289
- #
290
- # Binds can contain additional configuration, but only SSL config is really
291
- # relevant since the unix and TCP socket options are ignored.
292
- #
293
- # This means there is a lot of duplicated configuration for no additional
294
- # value in most setups. This method tells the launcher to bind to all
295
- # activated sockets, regardless of existing bind.
296
- #
297
- # To clear configured binds, the value only can be passed. This will clear
298
- # out any binds that may have been configured.
299
- #
300
- # @example Use any systemd activated sockets as well as configured binds
301
- # bind_to_activated_sockets
302
- #
303
- # @example Only bind to systemd activated sockets, ignoring other binds
304
- # bind_to_activated_sockets 'only'
305
- def bind_to_activated_sockets(bind=true)
306
- @options[:bind_to_activated_sockets] = bind
307
- end
308
-
309
- # Define the TCP port to bind to. Use +bind+ for more advanced options.
310
- #
311
- # @example
312
- # port 9292
313
- def port(port, host=nil)
314
- host ||= default_host
315
- bind URI::Generic.build(scheme: 'tcp', host: host, port: Integer(port)).to_s
316
- end
317
-
318
- # Define how long the tcp socket stays open, if no data has been received.
319
- # @see Puma::Server.new
320
- def first_data_timeout(seconds)
321
- @options[:first_data_timeout] = Integer(seconds)
322
- end
323
-
324
- # Define how long persistent connections can be idle before Puma closes them.
325
- # @see Puma::Server.new
326
- def persistent_timeout(seconds)
327
- @options[:persistent_timeout] = Integer(seconds)
328
- end
329
-
330
- # If a new request is not received within this number of seconds, begin shutting down.
331
- # @see Puma::Server.new
332
- def idle_timeout(seconds)
333
- @options[:idle_timeout] = Integer(seconds)
334
- end
335
-
336
- # Work around leaky apps that leave garbage in Thread locals
337
- # across requests.
338
- def clean_thread_locals(which=true)
339
- @options[:clean_thread_locals] = which
340
- end
341
-
342
- # When shutting down, drain the accept socket of pending connections and
343
- # process them. This loops over the accept socket until there are no more
344
- # read events and then stops looking and waits for the requests to finish.
345
- # @see Puma::Server#graceful_shutdown
346
- #
347
- def drain_on_shutdown(which=true)
348
- @options[:drain_on_shutdown] = which
349
- end
350
-
351
- # Set the environment in which the rack's app will run. The value must be
352
- # a string.
353
- #
354
- # The default is "development".
355
- #
356
- # @example
357
- # environment 'production'
358
- def environment(environment)
359
- @options[:environment] = environment
360
- end
361
-
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.
366
- #
367
- # Puma always waits a few seconds after killing a thread for it to try
368
- # to finish up it's work, even in :immediately mode.
369
- # @see Puma::Server#graceful_shutdown
370
- def force_shutdown_after(val=:forever)
371
- i = case val
372
- when :forever
373
- -1
374
- when :immediately
375
- 0
376
- else
377
- Float(val)
378
- end
379
-
380
- @options[:force_shutdown_after] = i
381
- end
382
-
383
- # Code to run before doing a restart. This code should
384
- # close log files, database connections, etc.
385
- #
386
- # This can be called multiple times to add code each time.
387
- #
388
- # @example
389
- # on_restart do
390
- # puts 'On restart...'
391
- # end
392
- def on_restart(&block)
393
- @options[:on_restart] ||= []
394
- @options[:on_restart] << block
395
- end
396
-
397
- # Command to use to restart Puma. This should be just how to
398
- # load Puma itself (ie. 'ruby -Ilib bin/puma'), not the arguments
399
- # to Puma, as those are the same as the original process.
400
- #
401
- # @example
402
- # restart_command '/u/app/lolcat/bin/restart_puma'
403
- def restart_command(cmd)
404
- @options[:restart_cmd] = cmd.to_s
405
- end
406
-
407
- # Store the pid of the server in the file at "path".
408
- #
409
- # @example
410
- # pidfile '/u/apps/lolcat/tmp/pids/puma.pid'
411
- def pidfile(path)
412
- @options[:pidfile] = path.to_s
413
- end
414
-
415
- # Disable request logging, if this isn't used it'll be enabled by default.
416
- #
417
- # @example
418
- # quiet
419
- def quiet(which=true)
420
- @options[:log_requests] = !which
421
- end
422
-
423
- # Enable request logging
424
- #
425
- def log_requests(which=true)
426
- @options[:log_requests] = which
427
- end
428
-
429
- # Pass in a custom logging class instance
430
- def custom_logger(custom_logger)
431
- @options[:custom_logger] = custom_logger
432
- end
433
-
434
- # Show debugging info
435
- #
436
- def debug
437
- @options[:debug] = true
438
- end
439
-
440
- # Load +path+ as a rackup file.
441
- #
442
- # The default is "config.ru".
443
- #
444
- # @example
445
- # rackup '/u/apps/lolcat/config.ru'
446
- def rackup(path)
447
- @options[:rackup] ||= path.to_s
448
- end
449
-
450
- # Allows setting `env['rack.url_scheme']`.
451
- # Only necessary if X-Forwarded-Proto is not being set by your proxy
452
- # Normal values are 'http' or 'https'.
453
- def rack_url_scheme(scheme=nil)
454
- @options[:rack_url_scheme] = scheme
455
- end
456
-
457
- def early_hints(answer=true)
458
- @options[:early_hints] = answer
459
- end
460
-
461
- # Redirect +STDOUT+ and +STDERR+ to files specified. The +append+ parameter
462
- # specifies whether the output is appended, the default is +false+.
463
- #
464
- # @example
465
- # stdout_redirect '/app/lolcat/log/stdout', '/app/lolcat/log/stderr'
466
- # @example
467
- # stdout_redirect '/app/lolcat/log/stdout', '/app/lolcat/log/stderr', true
468
- def stdout_redirect(stdout=nil, stderr=nil, append=false)
469
- @options[:redirect_stdout] = stdout
470
- @options[:redirect_stderr] = stderr
471
- @options[:redirect_append] = append
472
- end
473
-
474
- def log_formatter(&block)
475
- @options[:log_formatter] = block
476
- end
477
-
478
- # Configure +min+ to be the minimum number of threads to use to answer
479
- # requests and +max+ the maximum.
480
- #
481
- # The default is the environment variables +PUMA_MIN_THREADS+ / +PUMA_MAX_THREADS+
482
- # (or +MIN_THREADS+ / +MAX_THREADS+ if the +PUMA_+ variables aren't set).
483
- #
484
- # If these environment variables aren't set, the default is "0, 5" in MRI or "0, 16" for other interpreters.
485
- #
486
- # @example
487
- # threads 0, 16
488
- # @example
489
- # threads 5, 5
490
- def threads(min, max)
491
- min = Integer(min)
492
- max = Integer(max)
493
- if min > max
494
- raise "The minimum (#{min}) number of threads must be less than or equal to the max (#{max})"
495
- end
496
-
497
- if max < 1
498
- raise "The maximum number of threads (#{max}) must be greater than 0"
499
- end
500
-
501
- @options[:min_threads] = min
502
- @options[:max_threads] = max
503
- end
504
-
505
- # Instead of using +bind+ and manually constructing a URI like:
506
- #
507
- # bind 'ssl://127.0.0.1:9292?key=key_path&cert=cert_path'
508
- #
509
- # you can use the this method.
510
- #
511
- # When binding on localhost you don't need to specify +cert+ and +key+,
512
- # Puma will assume you are using the +localhost+ gem and try to load the
513
- # appropriate files.
514
- #
515
- # When using the options hash parameter, the `reuse:` value is either
516
- # `true`, which sets reuse 'on' with default values, or a hash, with `:size`
517
- # and/or `:timeout` keys, each with integer values.
518
- #
519
- # The `cert:` options hash parameter can be the path to a certificate
520
- # file including all intermediate certificates in PEM format.
521
- #
522
- # The `cert_pem:` options hash parameter can be String containing the
523
- # cerificate and all intermediate certificates in PEM format.
524
- #
525
- # @example
526
- # ssl_bind '127.0.0.1', '9292', {
527
- # cert: path_to_cert,
528
- # key: path_to_key,
529
- # ssl_cipher_filter: cipher_filter, # optional
530
- # verify_mode: verify_mode, # default 'none'
531
- # verification_flags: flags, # optional, not supported by JRuby
532
- # reuse: true # optional
533
- # }
534
- #
535
- # @example Using self-signed certificate with the +localhost+ gem:
536
- # ssl_bind '127.0.0.1', '9292'
537
- #
538
- # @example Alternatively, you can provide +cert_pem+ and +key_pem+:
539
- # ssl_bind '127.0.0.1', '9292', {
540
- # cert_pem: File.read(path_to_cert),
541
- # key_pem: File.read(path_to_key),
542
- # reuse: {size: 2_000, timeout: 20} # optional
543
- # }
544
- #
545
- # @example For JRuby, two keys are required: +keystore+ & +keystore_pass+
546
- # ssl_bind '127.0.0.1', '9292', {
547
- # keystore: path_to_keystore,
548
- # keystore_pass: password,
549
- # ssl_cipher_list: cipher_list, # optional
550
- # verify_mode: verify_mode # default 'none'
551
- # }
552
- def ssl_bind(host, port, opts = {})
553
- add_pem_values_to_options_store(opts)
554
- bind self.class.ssl_bind_str(host, port, opts)
555
- end
556
-
557
- # Use +path+ as the file to store the server info state. This is
558
- # used by +pumactl+ to query and control the server.
559
- #
560
- # @example
561
- # state_path '/u/apps/lolcat/tmp/pids/puma.state'
562
- def state_path(path)
563
- @options[:state] = path.to_s
564
- end
565
-
566
- # Use +permission+ to restrict permissions for the state file.
567
- #
568
- # @example
569
- # state_permission 0600
570
- # @version 5.0.0
571
- #
572
- def state_permission(permission)
573
- @options[:state_permission] = permission
574
- end
575
-
576
- # How many worker processes to run. Typically this is set to
577
- # the number of available cores.
578
- #
579
- # The default is the value of the environment variable +WEB_CONCURRENCY+ if
580
- # set, otherwise 0.
581
- #
582
- # @note Cluster mode only.
583
- # @see Puma::Cluster
584
- def workers(count)
585
- @options[:workers] = count.to_i
586
- end
587
-
588
- # Disable warning message when running in cluster mode with a single worker.
589
- #
590
- # Cluster mode has some overhead of running an additional 'control' process
591
- # in order to manage the cluster. If only running a single worker it is
592
- # likely not worth paying that overhead vs running in single mode with
593
- # additional threads instead.
594
- #
595
- # There are some scenarios where running cluster mode with a single worker
596
- # may still be warranted and valid under certain deployment scenarios, see
597
- # https://github.com/puma/puma/issues/2534
598
- #
599
- # Moving from workers = 1 to workers = 0 will save 10-30% of memory use.
600
- #
601
- # @note Cluster mode only.
602
- def silence_single_worker_warning
603
- @options[:silence_single_worker_warning] = true
604
- end
605
-
606
- # Disable warning message when running single mode with callback hook defined.
607
- def silence_fork_callback_warning
608
- @options[:silence_fork_callback_warning] = true
609
- end
610
-
611
- # Code to run immediately before master process
612
- # forks workers (once on boot). These hooks can block if necessary
613
- # to wait for background operations unknown to Puma to finish before
614
- # the process terminates.
615
- # This can be used to close any connections to remote servers (database,
616
- # Redis, ...) that were opened when preloading the code.
617
- #
618
- # This can be called multiple times to add several hooks.
619
- #
620
- # @note Cluster mode only.
621
- # @example
622
- # before_fork do
623
- # puts "Starting workers..."
624
- # end
625
- def before_fork(&block)
626
- warn_if_in_single_mode('before_fork')
627
-
628
- @options[:before_fork] ||= []
629
- @options[:before_fork] << block
630
- end
631
-
632
- # Code to run in a worker when it boots to setup
633
- # the process before booting the app.
634
- #
635
- # This can be called multiple times to add several hooks.
636
- #
637
- # @note Cluster mode only.
638
- # @example
639
- # on_worker_boot do
640
- # puts 'Before worker boot...'
641
- # end
642
- def on_worker_boot(key = nil, &block)
643
- warn_if_in_single_mode('on_worker_boot')
644
-
645
- process_hook :before_worker_boot, key, block, 'on_worker_boot'
646
- end
647
-
648
- # Code to run immediately before a worker shuts
649
- # down (after it has finished processing HTTP requests). These hooks
650
- # can block if necessary to wait for background operations unknown
651
- # to Puma to finish before the process terminates.
652
- #
653
- # This can be called multiple times to add several hooks.
654
- #
655
- # @note Cluster mode only.
656
- # @example
657
- # on_worker_shutdown do
658
- # puts 'On worker shutdown...'
659
- # end
660
- def on_worker_shutdown(key = nil, &block)
661
- warn_if_in_single_mode('on_worker_shutdown')
662
-
663
- process_hook :before_worker_shutdown, key, block, 'on_worker_shutdown'
664
- end
665
-
666
- # Code to run in the master right before a worker is started. The worker's
667
- # index is passed as an argument.
668
- #
669
- # This can be called multiple times to add several hooks.
670
- #
671
- # @note Cluster mode only.
672
- # @example
673
- # on_worker_fork do
674
- # puts 'Before worker fork...'
675
- # end
676
- def on_worker_fork(&block)
677
- warn_if_in_single_mode('on_worker_fork')
678
-
679
- process_hook :before_worker_fork, nil, block, 'on_worker_fork'
680
- end
681
-
682
- # Code to run in the master after a worker has been started. The worker's
683
- # index is passed as an argument.
684
- #
685
- # This is called everytime a worker is to be started.
686
- #
687
- # @note Cluster mode only.
688
- # @example
689
- # after_worker_fork do
690
- # puts 'After worker fork...'
691
- # end
692
- def after_worker_fork(&block)
693
- warn_if_in_single_mode('after_worker_fork')
694
-
695
- process_hook :after_worker_fork, nil, block, 'after_worker_fork'
696
- end
697
-
698
- alias_method :after_worker_boot, :after_worker_fork
699
-
700
- # Code to run after puma is booted (works for both: single and clustered)
701
- #
702
- # @example
703
- # on_booted do
704
- # puts 'After booting...'
705
- # end
706
- def on_booted(&block)
707
- @config.options[:events].on_booted(&block)
708
- end
709
-
710
- # When `fork_worker` is enabled, code to run in Worker 0
711
- # before all other workers are re-forked from this process,
712
- # after the server has temporarily stopped serving requests
713
- # (once per complete refork cycle).
714
- #
715
- # This can be used to trigger extra garbage-collection to maximize
716
- # copy-on-write efficiency, or close any connections to remote servers
717
- # (database, Redis, ...) that were opened while the server was running.
718
- #
719
- # This can be called multiple times to add several hooks.
720
- #
721
- # @note Cluster mode with `fork_worker` enabled only.
722
- # @example
723
- # on_refork do
724
- # 3.times {GC.start}
725
- # end
726
- # @version 5.0.0
727
- #
728
- def on_refork(key = nil, &block)
729
- process_hook :before_refork, key, block, 'on_refork'
730
- end
731
-
732
- # Provide a block to be executed just before a thread is added to the thread
733
- # pool. Be careful: while the block executes, thread creation is delayed, and
734
- # probably a request will have to wait too! The new thread will not be added to
735
- # the threadpool until the provided block returns.
736
- #
737
- # Return values are ignored.
738
- # Raising an exception will log a warning.
739
- #
740
- # This hook is useful for doing something when the thread pool grows.
741
- #
742
- # This can be called multiple times to add several hooks.
743
- #
744
- # @example
745
- # on_thread_start do
746
- # puts 'On thread start...'
747
- # end
748
- def on_thread_start(&block)
749
- @options[:before_thread_start] ||= []
750
- @options[:before_thread_start] << block
751
- end
752
-
753
- # Provide a block to be executed after a thread is trimmed from the thread
754
- # pool. Be careful: while this block executes, Puma's main loop is
755
- # blocked, so no new requests will be picked up.
756
- #
757
- # This hook only runs when a thread in the threadpool is trimmed by Puma.
758
- # It does not run when a thread dies due to exceptions or any other cause.
759
- #
760
- # Return values are ignored.
761
- # Raising an exception will log a warning.
762
- #
763
- # This hook is useful for cleaning up thread local resources when a thread
764
- # is trimmed.
765
- #
766
- # This can be called multiple times to add several hooks.
767
- #
768
- # @example
769
- # on_thread_exit do
770
- # puts 'On thread exit...'
771
- # end
772
- def on_thread_exit(&block)
773
- @options[:before_thread_exit] ||= []
774
- @options[:before_thread_exit] << block
775
- end
776
-
777
- # Code to run out-of-band when the worker is idle.
778
- # These hooks run immediately after a request has finished
779
- # processing and there are no busy threads on the worker.
780
- # The worker doesn't accept new requests until this code finishes.
781
- #
782
- # This hook is useful for running out-of-band garbage collection
783
- # or scheduling asynchronous tasks to execute after a response.
784
- #
785
- # This can be called multiple times to add several hooks.
786
- def out_of_band(&block)
787
- process_hook :out_of_band, nil, block, 'out_of_band'
788
- end
789
-
790
- # The directory to operate out of.
791
- #
792
- # The default is the current directory.
793
- #
794
- # @example
795
- # directory '/u/apps/lolcat'
796
- def directory(dir)
797
- @options[:directory] = dir.to_s
798
- end
799
-
800
- # 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.
802
- #
803
- # @note Cluster mode only.
804
- # @example
805
- # preload_app!
806
- def preload_app!(answer=true)
807
- @options[:preload_app] = answer
808
- end
809
-
810
- # Use +obj+ or +block+ as the low level error handler. This allows the
811
- # configuration file to change the default error on the server.
812
- #
813
- # @example
814
- # lowlevel_error_handler do |err|
815
- # [200, {}, ["error page"]]
816
- # end
817
- def lowlevel_error_handler(obj=nil, &block)
818
- obj ||= block
819
- raise "Provide either a #call'able or a block" unless obj
820
- @options[:lowlevel_error_handler] = obj
821
- end
822
-
823
- # This option is used to allow your app and its gems to be
824
- # properly reloaded when not using preload.
825
- #
826
- # When set, if Puma detects that it's been invoked in the
827
- # context of Bundler, it will cleanup the environment and
828
- # re-run itself outside the Bundler environment, but directly
829
- # using the files that Bundler has setup.
830
- #
831
- # This means that Puma is now decoupled from your Bundler
832
- # context and when each worker loads, it will be loading a
833
- # new Bundler context and thus can float around as the release
834
- # dictates.
835
- #
836
- # @see extra_runtime_dependencies
837
- #
838
- # @note This is incompatible with +preload_app!+.
839
- # @note This is only supported for RubyGems 2.2+
840
- def prune_bundler(answer=true)
841
- @options[:prune_bundler] = answer
842
- end
843
-
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.
847
- #
848
- # This can be useful for example in Kubernetes, where rolling restart is
849
- # guaranteed usually on infrastructure level.
850
- #
851
- # @example
852
- # raise_exception_on_sigterm false
853
- # @see Puma::Launcher#setup_signals
854
- # @see Puma::Cluster#setup_signals
855
- #
856
- def raise_exception_on_sigterm(answer=true)
857
- @options[:raise_exception_on_sigterm] = answer
858
- end
859
-
860
- # When using prune_bundler, if extra runtime dependencies need to be loaded to
861
- # initialize your app, then this setting can be used. This includes any Puma plugins.
862
- #
863
- # Before bundler is pruned, the gem names supplied will be looked up in the bundler
864
- # context and then loaded again after bundler is pruned.
865
- # Only applies if prune_bundler is used.
866
- #
867
- # @example
868
- # extra_runtime_dependencies ['gem_name_1', 'gem_name_2']
869
- # @example
870
- # extra_runtime_dependencies ['puma_worker_killer', 'puma-heroku']
871
- # @see Puma::Launcher#extra_runtime_deps_directories
872
- #
873
- def extra_runtime_dependencies(answer = [])
874
- @options[:extra_runtime_dependencies] = Array(answer)
875
- end
876
-
877
- # Additional text to display in process listing.
878
- #
879
- # If you do not specify a tag, Puma will infer it. If you do not want Puma
880
- # to add a tag, use an empty string.
881
- #
882
- # @example
883
- # tag 'app name'
884
- # @example
885
- # tag ''
886
- def tag(string)
887
- @options[:tag] = string.to_s
888
- end
889
-
890
- # Change the default interval for checking workers.
891
- #
892
- # The default value is 5 seconds.
893
- #
894
- # @note Cluster mode only.
895
- # @example
896
- # worker_check_interval 5
897
- # @see Puma::Cluster#check_workers
898
- #
899
- def worker_check_interval(interval)
900
- @options[:worker_check_interval] = Integer(interval)
901
- end
902
-
903
- # Verifies that all workers have checked in to the master process within
904
- # the given timeout. If not the worker process will be restarted. This is
905
- # not a request timeout, it is to protect against a hung or dead process.
906
- # Setting this value will not protect against slow requests.
907
- #
908
- # This value must be greater than worker_check_interval.
909
- # The default value is 60 seconds.
910
- #
911
- # @note Cluster mode only.
912
- # @example
913
- # worker_timeout 60
914
- # @see Puma::Cluster::Worker#ping_timeout
915
- #
916
- def worker_timeout(timeout)
917
- timeout = Integer(timeout)
918
- min = @options.fetch(:worker_check_interval, Configuration::DEFAULTS[:worker_check_interval])
919
-
920
- if timeout <= min
921
- raise "The minimum worker_timeout must be greater than the worker reporting interval (#{min})"
922
- end
923
-
924
- @options[:worker_timeout] = timeout
925
- end
926
-
927
- # Change the default worker timeout for booting.
928
- #
929
- # If unspecified, this defaults to the value of worker_timeout.
930
- #
931
- # @note Cluster mode only.
932
- #
933
- # @example
934
- # worker_boot_timeout 60
935
- # @see Puma::Cluster::Worker#ping_timeout
936
- #
937
- def worker_boot_timeout(timeout)
938
- @options[:worker_boot_timeout] = Integer(timeout)
939
- end
940
-
941
- # Set the timeout for worker shutdown.
942
- #
943
- # @note Cluster mode only.
944
- # @see Puma::Cluster::Worker#term
945
- #
946
- def worker_shutdown_timeout(timeout)
947
- @options[:worker_shutdown_timeout] = Integer(timeout)
948
- end
949
-
950
- # Set the strategy for worker culling.
951
- #
952
- # There are two possible values:
953
- #
954
- # 1. **:youngest** - the youngest workers (i.e. the workers that were
955
- # the most recently started) will be culled.
956
- # 2. **:oldest** - the oldest workers (i.e. the workers that were started
957
- # the longest time ago) will be culled.
958
- #
959
- # @note Cluster mode only.
960
- # @example
961
- # worker_culling_strategy :oldest
962
- # @see Puma::Cluster#cull_workers
963
- #
964
- def worker_culling_strategy(strategy)
965
- stategy = strategy.to_sym
966
-
967
- if ![:youngest, :oldest].include?(strategy)
968
- raise "Invalid value for worker_culling_strategy - #{stategy}"
969
- end
970
-
971
- @options[:worker_culling_strategy] = strategy
972
- end
973
-
974
- # When set to true (the default), workers accept all requests
975
- # and queue them before passing them to the handlers.
976
- # When set to false, each worker process accepts exactly as
977
- # many requests as it is configured to simultaneously handle.
978
- #
979
- # Queueing requests generally improves performance. In some
980
- # cases, such as a single threaded application, it may be
981
- # better to ensure requests get balanced across workers.
982
- #
983
- # Note that setting this to false disables HTTP keepalive and
984
- # slow clients will occupy a handler thread while the request
985
- # is being sent. A reverse proxy, such as nginx, can handle
986
- # slow clients and queue requests before they reach Puma.
987
- # @see Puma::Server
988
- def queue_requests(answer=true)
989
- @options[:queue_requests] = answer
990
- end
991
-
992
- # When a shutdown is requested, the backtraces of all the
993
- # threads will be written to $stdout. This can help figure
994
- # out why shutdown is hanging.
995
- #
996
- def shutdown_debug(val=true)
997
- @options[:shutdown_debug] = val
998
- end
999
-
1000
-
1001
- # Attempts to route traffic to less-busy workers by causing them to delay
1002
- # listening on the socket, allowing workers which are not processing any
1003
- # requests to pick up new requests first.
1004
- #
1005
- # Only works on MRI. For all other interpreters, this setting does nothing.
1006
- # @see Puma::Server#handle_servers
1007
- # @see Puma::ThreadPool#wait_for_less_busy_worker
1008
- # @version 5.0.0
1009
- #
1010
- def wait_for_less_busy_worker(val=0.005)
1011
- @options[:wait_for_less_busy_worker] = val.to_f
1012
- end
1013
-
1014
- # Control how the remote address of the connection is set. This
1015
- # is configurable because to calculate the true socket peer address
1016
- # a kernel syscall is required which for very fast rack handlers
1017
- # slows down the handling significantly.
1018
- #
1019
- # There are 5 possible values:
1020
- #
1021
- # 1. **:socket** (the default) - read the peername from the socket using the
1022
- # syscall. This is the normal behavior. If this fails for any reason (e.g.,
1023
- # if the peer disconnects between the connection being accepted and the getpeername
1024
- # system call), Puma will return "0.0.0.0"
1025
- # 2. **:localhost** - set the remote address to "127.0.0.1"
1026
- # 3. **header: <http_header>**- set the remote address to the value of the
1027
- # provided http header. For instance:
1028
- # `set_remote_address header: "X-Real-IP"`.
1029
- # Only the first word (as separated by spaces or comma) is used, allowing
1030
- # headers such as X-Forwarded-For to be used as well. If this header is absent,
1031
- # Puma will fall back to the behavior of :socket
1032
- # 4. **proxy_protocol: :v1**- set the remote address to the value read from the
1033
- # HAproxy PROXY protocol, version 1. If the request does not have the PROXY
1034
- # protocol attached to it, will fall back to :socket
1035
- # 5. **\<Any string\>** - this allows you to hardcode remote address to any value
1036
- # you wish. Because Puma never uses this field anyway, it's format is
1037
- # entirely in your hands.
1038
- #
1039
- def set_remote_address(val=:socket)
1040
- case val
1041
- when :socket
1042
- @options[:remote_address] = val
1043
- when :localhost
1044
- @options[:remote_address] = :value
1045
- @options[:remote_address_value] = "127.0.0.1".freeze
1046
- when String
1047
- @options[:remote_address] = :value
1048
- @options[:remote_address_value] = val
1049
- when Hash
1050
- if hdr = val[:header]
1051
- @options[:remote_address] = :header
1052
- @options[:remote_address_header] = "HTTP_" + hdr.upcase.tr("-", "_")
1053
- elsif protocol_version = val[:proxy_protocol]
1054
- @options[:remote_address] = :proxy_protocol
1055
- protocol_version = protocol_version.downcase.to_sym
1056
- unless [:v1].include?(protocol_version)
1057
- raise "Invalid value for proxy_protocol - #{protocol_version.inspect}"
1058
- end
1059
- @options[:remote_address_proxy_protocol] = protocol_version
1060
- else
1061
- raise "Invalid value for set_remote_address - #{val.inspect}"
1062
- end
1063
- else
1064
- raise "Invalid value for set_remote_address - #{val}"
1065
- end
1066
- end
1067
-
1068
- # When enabled, workers will be forked from worker 0 instead of from the master process.
1069
- # This option is similar to `preload_app` because the app is preloaded before forking,
1070
- # but it is compatible with phased restart.
1071
- #
1072
- # This option also enables the `refork` command (SIGURG), which optimizes copy-on-write performance
1073
- # in a running app.
1074
- #
1075
- # A refork will automatically trigger once after the specified number of requests
1076
- # (default 1000), or pass 0 to disable auto refork.
1077
- #
1078
- # @note Cluster mode only.
1079
- # @version 5.0.0
1080
- #
1081
- def fork_worker(after_requests=1000)
1082
- @options[:fork_worker] = Integer(after_requests)
1083
- end
1084
-
1085
- # The number of requests to attempt inline before sending a client back to
1086
- # the reactor to be subject to normal ordering.
1087
- #
1088
- def max_fast_inline(num_of_requests)
1089
- @options[:max_fast_inline] = Float(num_of_requests)
1090
- end
1091
-
1092
- # Specify the backend for the IO selector.
1093
- #
1094
- # Provided values will be passed directly to +NIO::Selector.new+, with the
1095
- # exception of +:auto+ which will let nio4r choose the backend.
1096
- #
1097
- # Check the documentation of +NIO::Selector.backends+ for the list of valid
1098
- # options. Note that the available options on your system will depend on the
1099
- # operating system. If you want to use the pure Ruby backend (not
1100
- # recommended due to its comparatively low performance), set environment
1101
- # variable +NIO4R_PURE+ to +true+.
1102
- #
1103
- # The default is +:auto+.
1104
- #
1105
- # @see https://github.com/socketry/nio4r/blob/master/lib/nio/selector.rb
1106
- #
1107
- def io_selector_backend(backend)
1108
- @options[:io_selector_backend] = backend.to_sym
1109
- end
1110
-
1111
- def mutate_stdout_and_stderr_to_sync_on_write(enabled=true)
1112
- @options[:mutate_stdout_and_stderr_to_sync_on_write] = enabled
1113
- end
1114
-
1115
- # Specify how big the request payload should be, in bytes.
1116
- # This limit is compared against Content-Length HTTP header.
1117
- # If the payload size (CONTENT_LENGTH) is larger than http_content_length_limit,
1118
- # HTTP 413 status code is returned.
1119
- #
1120
- # When no Content-Length http header is present, it is compared against the
1121
- # size of the body of the request.
1122
- #
1123
- # The default value for http_content_length_limit is nil.
1124
- def http_content_length_limit(limit)
1125
- @options[:http_content_length_limit] = limit
1126
- end
1127
-
1128
- # Supported http methods, which will replace `Puma::Const::SUPPORTED_HTTP_METHODS`.
1129
- # The value of `:any` will allows all methods, otherwise, the value must be
1130
- # an array of strings. Note that methods are all uppercase.
1131
- #
1132
- # `Puma::Const::SUPPORTED_HTTP_METHODS` is conservative, if you want a
1133
- # complete set of methods, the methods defined by the
1134
- # [IANA Method Registry](https://www.iana.org/assignments/http-methods/http-methods.xhtml)
1135
- # are pre-defined as the constant `Puma::Const::IANA_HTTP_METHODS`.
1136
- #
1137
- # @note If the `methods` value is `:any`, no method check with be performed,
1138
- # similar to Puma v5 and earlier.
1139
- #
1140
- # @example Adds 'PROPFIND' to existing supported methods
1141
- # supported_http_methods(Puma::Const::SUPPORTED_HTTP_METHODS + ['PROPFIND'])
1142
- # @example Restricts methods to the array elements
1143
- # supported_http_methods %w[HEAD GET POST PUT DELETE OPTIONS PROPFIND]
1144
- # @example Restricts methods to the methods in the IANA Registry
1145
- # supported_http_methods Puma::Const::IANA_HTTP_METHODS
1146
- # @example Allows any method
1147
- # supported_http_methods :any
1148
- #
1149
- def supported_http_methods(methods)
1150
- if methods == :any
1151
- @options[:supported_http_methods] = :any
1152
- elsif Array === methods && methods == (ary = methods.grep(String).uniq) &&
1153
- !ary.empty?
1154
- @options[:supported_http_methods] = ary
1155
- else
1156
- raise "supported_http_methods must be ':any' or a unique array of strings"
1157
- end
1158
- end
1159
-
1160
- private
1161
-
1162
- # To avoid adding cert_pem and key_pem as URI params, we store them on the
1163
- # options[:store] from where Puma binder knows how to find and extract them.
1164
- def add_pem_values_to_options_store(opts)
1165
- return if defined?(JRUBY_VERSION)
1166
-
1167
- @options[:store] ||= []
1168
-
1169
- # Store cert_pem and key_pem to options[:store] if present
1170
- [:cert, :key].each do |v|
1171
- opt_key = :"#{v}_pem"
1172
- if opts[opt_key]
1173
- index = @options[:store].length
1174
- @options[:store] << opts[opt_key]
1175
- opts[v] = "store:#{index}"
1176
- end
1177
- end
1178
- end
1179
-
1180
- def process_hook(options_key, key, block, meth)
1181
- @options[options_key] ||= []
1182
- if ON_WORKER_KEY.include? key.class
1183
- @options[options_key] << [block, key.to_sym]
1184
- elsif key.nil?
1185
- @options[options_key] << block
1186
- else
1187
- raise "'#{meth}' key must be String or Symbol"
1188
- end
1189
- end
1190
-
1191
- def warn_if_in_single_mode(hook_name)
1192
- return if @options[:silence_fork_callback_warning]
1193
- # user_options (CLI) have precedence over config file
1194
- if (@config.options.user_options[:workers] || @options[:workers] || 0) == 0
1195
- log_string =
1196
- "Warning: You specified code to run in a `#{hook_name}` block, " \
1197
- "but Puma is not configured to run in cluster mode (worker count > 0 ), " \
1198
- "so your `#{hook_name}` block did not run"
1199
-
1200
- LogWriter.stdio.log(log_string)
1201
- end
1202
- end
1203
- end
1204
- end