tiny-fast-gem 0.0.1

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 (99) hide show
  1. checksums.yaml +7 -0
  2. data/puma-8.0.2/History.md +3334 -0
  3. data/puma-8.0.2/LICENSE +29 -0
  4. data/puma-8.0.2/README.md +484 -0
  5. data/puma-8.0.2/bin/puma +10 -0
  6. data/puma-8.0.2/bin/puma-wild +25 -0
  7. data/puma-8.0.2/bin/pumactl +12 -0
  8. data/puma-8.0.2/docs/5.0-Upgrade.md +98 -0
  9. data/puma-8.0.2/docs/6.0-Upgrade.md +56 -0
  10. data/puma-8.0.2/docs/7.0-Upgrade.md +52 -0
  11. data/puma-8.0.2/docs/8.0-Upgrade.md +100 -0
  12. data/puma-8.0.2/docs/architecture.md +74 -0
  13. data/puma-8.0.2/docs/compile_options.md +55 -0
  14. data/puma-8.0.2/docs/deployment.md +137 -0
  15. data/puma-8.0.2/docs/fork_worker.md +41 -0
  16. data/puma-8.0.2/docs/grpc.md +62 -0
  17. data/puma-8.0.2/docs/images/favicon.svg +1 -0
  18. data/puma-8.0.2/docs/images/puma-connection-flow-no-reactor.png +0 -0
  19. data/puma-8.0.2/docs/images/puma-connection-flow.png +0 -0
  20. data/puma-8.0.2/docs/images/puma-general-arch.png +0 -0
  21. data/puma-8.0.2/docs/images/running-puma.svg +1 -0
  22. data/puma-8.0.2/docs/images/standard-logo.svg +1 -0
  23. data/puma-8.0.2/docs/java_options.md +54 -0
  24. data/puma-8.0.2/docs/jungle/README.md +9 -0
  25. data/puma-8.0.2/docs/jungle/rc.d/README.md +74 -0
  26. data/puma-8.0.2/docs/jungle/rc.d/puma +61 -0
  27. data/puma-8.0.2/docs/jungle/rc.d/puma.conf +10 -0
  28. data/puma-8.0.2/docs/kubernetes.md +73 -0
  29. data/puma-8.0.2/docs/nginx.md +80 -0
  30. data/puma-8.0.2/docs/plugins.md +42 -0
  31. data/puma-8.0.2/docs/rails_dev_mode.md +28 -0
  32. data/puma-8.0.2/docs/restart.md +65 -0
  33. data/puma-8.0.2/docs/signals.md +98 -0
  34. data/puma-8.0.2/docs/stats.md +148 -0
  35. data/puma-8.0.2/docs/systemd.md +253 -0
  36. data/puma-8.0.2/docs/testing_benchmarks_local_files.md +150 -0
  37. data/puma-8.0.2/docs/testing_test_rackup_ci_files.md +36 -0
  38. data/puma-8.0.2/ext/puma_http11/PumaHttp11Service.java +17 -0
  39. data/puma-8.0.2/ext/puma_http11/extconf.rb +65 -0
  40. data/puma-8.0.2/ext/puma_http11/http11_parser.c +1057 -0
  41. data/puma-8.0.2/ext/puma_http11/http11_parser.h +65 -0
  42. data/puma-8.0.2/ext/puma_http11/http11_parser.java.rl +131 -0
  43. data/puma-8.0.2/ext/puma_http11/http11_parser.rl +149 -0
  44. data/puma-8.0.2/ext/puma_http11/http11_parser_common.rl +54 -0
  45. data/puma-8.0.2/ext/puma_http11/mini_ssl.c +852 -0
  46. data/puma-8.0.2/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
  47. data/puma-8.0.2/ext/puma_http11/org/jruby/puma/EnvKey.java +241 -0
  48. data/puma-8.0.2/ext/puma_http11/org/jruby/puma/Http11.java +321 -0
  49. data/puma-8.0.2/ext/puma_http11/org/jruby/puma/Http11Parser.java +441 -0
  50. data/puma-8.0.2/ext/puma_http11/org/jruby/puma/MiniSSL.java +509 -0
  51. data/puma-8.0.2/ext/puma_http11/puma_http11.c +499 -0
  52. data/puma-8.0.2/lib/puma/app/status.rb +104 -0
  53. data/puma-8.0.2/lib/puma/binder.rb +511 -0
  54. data/puma-8.0.2/lib/puma/cli.rb +245 -0
  55. data/puma-8.0.2/lib/puma/client.rb +756 -0
  56. data/puma-8.0.2/lib/puma/client_env.rb +171 -0
  57. data/puma-8.0.2/lib/puma/cluster/worker.rb +183 -0
  58. data/puma-8.0.2/lib/puma/cluster/worker_handle.rb +127 -0
  59. data/puma-8.0.2/lib/puma/cluster.rb +634 -0
  60. data/puma-8.0.2/lib/puma/cluster_accept_loop_delay.rb +91 -0
  61. data/puma-8.0.2/lib/puma/commonlogger.rb +115 -0
  62. data/puma-8.0.2/lib/puma/configuration.rb +522 -0
  63. data/puma-8.0.2/lib/puma/const.rb +308 -0
  64. data/puma-8.0.2/lib/puma/control_cli.rb +320 -0
  65. data/puma-8.0.2/lib/puma/detect.rb +58 -0
  66. data/puma-8.0.2/lib/puma/dsl.rb +1562 -0
  67. data/puma-8.0.2/lib/puma/error_logger.rb +115 -0
  68. data/puma-8.0.2/lib/puma/events.rb +72 -0
  69. data/puma-8.0.2/lib/puma/io_buffer.rb +50 -0
  70. data/puma-8.0.2/lib/puma/jruby_restart.rb +11 -0
  71. data/puma-8.0.2/lib/puma/json_serialization.rb +96 -0
  72. data/puma-8.0.2/lib/puma/launcher/bundle_pruner.rb +102 -0
  73. data/puma-8.0.2/lib/puma/launcher.rb +501 -0
  74. data/puma-8.0.2/lib/puma/log_writer.rb +153 -0
  75. data/puma-8.0.2/lib/puma/minissl/context_builder.rb +96 -0
  76. data/puma-8.0.2/lib/puma/minissl.rb +458 -0
  77. data/puma-8.0.2/lib/puma/null_io.rb +101 -0
  78. data/puma-8.0.2/lib/puma/plugin/systemd.rb +90 -0
  79. data/puma-8.0.2/lib/puma/plugin/tmp_restart.rb +36 -0
  80. data/puma-8.0.2/lib/puma/plugin.rb +111 -0
  81. data/puma-8.0.2/lib/puma/rack/builder.rb +297 -0
  82. data/puma-8.0.2/lib/puma/rack/urlmap.rb +93 -0
  83. data/puma-8.0.2/lib/puma/rack_default.rb +24 -0
  84. data/puma-8.0.2/lib/puma/reactor.rb +131 -0
  85. data/puma-8.0.2/lib/puma/response.rb +532 -0
  86. data/puma-8.0.2/lib/puma/runner.rb +211 -0
  87. data/puma-8.0.2/lib/puma/sd_notify.rb +146 -0
  88. data/puma-8.0.2/lib/puma/server.rb +773 -0
  89. data/puma-8.0.2/lib/puma/server_plugin_control.rb +32 -0
  90. data/puma-8.0.2/lib/puma/single.rb +72 -0
  91. data/puma-8.0.2/lib/puma/state_file.rb +69 -0
  92. data/puma-8.0.2/lib/puma/thread_pool.rb +517 -0
  93. data/puma-8.0.2/lib/puma/util.rb +134 -0
  94. data/puma-8.0.2/lib/puma.rb +88 -0
  95. data/puma-8.0.2/lib/rack/handler/puma.rb +144 -0
  96. data/puma-8.0.2/tools/Dockerfile +26 -0
  97. data/puma-8.0.2/tools/trickletest.rb +44 -0
  98. data/tiny-fast-gem.gemspec +12 -0
  99. metadata +138 -0
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2019, Evan Phoenix. Some code by Zed Shaw, (c) 2005.
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,484 @@
1
+ <p align="center">
2
+ <img src="docs/images/standard-logo.svg" alt="Puma logo">
3
+ </p>
4
+
5
+ # Puma: A Ruby Web Server Built For Parallelism
6
+
7
+ [![Actions](https://github.com/puma/puma/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/puma/puma/actions/workflows/tests.yml?query=branch%3Amain)
8
+
9
+ Puma is a **simple, fast, multi-threaded, and highly parallel HTTP 1.1 server for Ruby/Rack applications**.
10
+
11
+ ## Built For Speed &amp; Parallelism
12
+
13
+ Puma is a server for [Rack](https://github.com/rack/rack)-powered HTTP applications written in Ruby. It is:
14
+ * **Multi-threaded**. Each request is served in a separate thread. This helps you serve more requests per second with less memory use.
15
+ * **Multi-process**. "Pre-forks" in cluster mode, using less memory per-process thanks to copy-on-write memory.
16
+ * **Standalone**. With SSL support, zero-downtime rolling restarts and a built-in request bufferer, you can deploy Puma without any reverse proxy.
17
+ * **Battle-tested**. Our HTTP parser is inherited from Mongrel and has over 15 years of production use. Puma is currently the most popular Ruby webserver, and is the default server for Ruby on Rails.
18
+
19
+ Originally designed as a server for [Rubinius](https://github.com/rubinius/rubinius), Puma also works well with Ruby (MRI) and JRuby.
20
+
21
+ On MRI, there is a Global VM Lock (GVL) that ensures only one thread can run Ruby code at a time. But if you're doing a lot of blocking IO (such as HTTP calls to external APIs like Twitter), Puma still improves MRI's throughput by allowing IO waiting to be done in parallel. Truly parallel Ruby implementations (TruffleRuby, JRuby) don't have this limitation.
22
+
23
+ ## Quick Start
24
+
25
+ ```
26
+ $ gem install puma
27
+ $ puma
28
+ ```
29
+
30
+ Without arguments, puma will look for a rackup (.ru) file in
31
+ working directory called `config.ru`.
32
+
33
+ ## SSL Connection Support
34
+
35
+ Puma will install/compile with support for ssl sockets, assuming OpenSSL
36
+ development files are installed on the system.
37
+
38
+ If the system does not have OpenSSL development files installed, Puma will
39
+ install/compile, but it will not allow ssl connections.
40
+
41
+ ## Frameworks
42
+
43
+ ### Rails
44
+
45
+ Puma is the default server for Rails, included in the generated Gemfile.
46
+
47
+ Start your server with the `rails` command:
48
+
49
+ ```
50
+ $ rails server
51
+ ```
52
+
53
+ Many configuration options and Puma features are not available when using `rails server`. It is recommended that you use Puma's executable instead:
54
+
55
+ ```
56
+ $ bundle exec puma
57
+ ```
58
+
59
+ ### Sinatra
60
+
61
+ You can run your Sinatra application with Puma from the command line like this:
62
+
63
+ ```
64
+ $ ruby app.rb -s Puma
65
+ ```
66
+
67
+ In order to actually configure Puma using a config file, like `puma.rb`, however, you need to use the `puma` executable. To do this, you must add a rackup file to your Sinatra app:
68
+
69
+ ```ruby
70
+ # config.ru
71
+ require './app'
72
+ run Sinatra::Application
73
+ ```
74
+
75
+ You can then start your application using:
76
+
77
+ ```
78
+ $ bundle exec puma
79
+ ```
80
+
81
+ ## Configuration
82
+
83
+ Puma provides numerous options. Consult `puma -h` (or `puma --help`) for a full list of CLI options, or see `Puma::DSL` or [dsl.rb](https://github.com/puma/puma/blob/main/lib/puma/dsl.rb).
84
+
85
+ You can also find several configuration examples as part of the
86
+ [test](https://github.com/puma/puma/tree/main/test/config) suite.
87
+
88
+ For debugging purposes, you can set the environment variable `PUMA_LOG_CONFIG` with a value
89
+ and the loaded configuration will be printed as part of the boot process.
90
+
91
+ ### Thread Pool
92
+
93
+ Puma uses a thread pool. You can set the minimum and maximum number of threads that are available in the pool with the `-t` (or `--threads`) flag:
94
+
95
+ ```
96
+ $ puma -t 8:32
97
+ ```
98
+
99
+ Puma will automatically scale the number of threads, from the minimum until it caps out at the maximum, based on how much traffic is present. The current default is `0:16` and on MRI is `0:5`. Feel free to experiment, but be careful not to set the number of maximum threads to a large number, as you may exhaust resources on the system (or cause contention for the Global VM Lock, when using MRI).
100
+
101
+ Be aware that additionally Puma creates threads on its own for internal purposes (e.g. handling slow clients). So, even if you specify -t 1:1, expect around 7 threads created in your application.
102
+
103
+ ### Cluster mode
104
+
105
+ Puma also offers "cluster mode". Cluster mode `fork`s workers from a master process. Each child process still has its own thread pool. You can tune the number of workers with the `-w` (or `--workers`) flag:
106
+
107
+ ```
108
+ $ puma -t 8:32 -w 3
109
+ ```
110
+
111
+ Or with the `WEB_CONCURRENCY` environment variable:
112
+
113
+ ```
114
+ $ WEB_CONCURRENCY=3 puma -t 8:32
115
+ ```
116
+
117
+ When using a config file, most applications can simply set `workers :auto` (requires the `concurrent-ruby` gem) to match the number of worker processes to the available processors:
118
+
119
+ ```ruby
120
+ # config/puma.rb
121
+ workers :auto
122
+ ```
123
+
124
+ See [`workers :auto` gotchas](lib/puma/dsl.rb).
125
+
126
+ Note that threads are still used in cluster mode, and the `-t` thread flag setting is per worker, so `-w 2 -t 16:16` will spawn 32 threads in total, with 16 in each worker process.
127
+
128
+ If `workers` is set to `:auto`, or the `WEB_CONCURRENCY` environment variable is set to `"auto"`, and the `concurrent-ruby` gem is available in your application, Puma will set the worker process count to the result of [available processors](https://msp-greg.github.io/concurrent-ruby/Concurrent.html#available_processor_count-class_method).
129
+
130
+ For an in-depth discussion of the tradeoffs of thread and process count settings, [see our docs](docs/deployment.md).
131
+
132
+ In cluster mode, Puma can "preload" your application. This loads all the application code *prior* to forking. Preloading reduces total memory usage of your application via an operating system feature called [copy-on-write](https://en.wikipedia.org/wiki/Copy-on-write).
133
+
134
+ If the number of workers is greater than 1 (and `--prune-bundler` has not been specified), preloading will be enabled by default. Otherwise, you can use the `--preload` flag from the command line:
135
+
136
+ ```
137
+ $ puma -w 3 --preload
138
+ ```
139
+
140
+ Or, if you're using a configuration file, you can use the `preload_app!` method:
141
+
142
+ ```ruby
143
+ # config/puma.rb
144
+ workers 3
145
+ preload_app!
146
+ ```
147
+
148
+ Preloading can’t be used with phased restart, since phased restart kills and restarts workers one-by-one, and preloading copies the code of master into the workers.
149
+
150
+ #### Cluster mode hooks
151
+
152
+ When using clustered mode, Puma's configuration DSL provides `before_fork`, `before_worker_boot`, and `after_worker_shutdown`
153
+ hooks to run code when the master process forks, the child workers are booted, and after each child worker exits respectively.
154
+
155
+ It is recommended to use these hooks with `preload_app!`, otherwise constants loaded by your
156
+ application (such as `Rails`) will not be available inside the hooks.
157
+
158
+ ```ruby
159
+ # config/puma.rb
160
+ before_fork do
161
+ # Add code to run inside the Puma master process before it forks a worker child.
162
+ end
163
+
164
+ before_worker_boot do
165
+ # Add code to run inside the Puma worker process after forking.
166
+ end
167
+
168
+ after_worker_shutdown do |worker_handle|
169
+ # Add code to run inside the Puma master process after a worker exits. `worker.process_status` can be used to get the
170
+ # `Process::Status` of the exited worker.
171
+ end
172
+ ```
173
+
174
+ In addition, there is an `before_refork` and `after_refork` hooks which are used only in [`fork_worker` mode](docs/fork_worker.md),
175
+ when the worker 0 child process forks a grandchild worker:
176
+
177
+ ```ruby
178
+ before_refork do
179
+ # Used only when fork_worker mode is enabled. Add code to run inside the Puma worker 0
180
+ # child process before it forks a grandchild worker.
181
+ end
182
+ ```
183
+
184
+ ```ruby
185
+ after_refork do
186
+ # Used only when fork_worker mode is enabled. Add code to run inside the Puma worker 0
187
+ # child process after it forks a grandchild worker.
188
+ end
189
+ ```
190
+
191
+ Importantly, note the following considerations when Ruby forks a child process:
192
+
193
+ 1. File descriptors such as network sockets **are** copied from the parent to the forked
194
+ child process. Dual-use of the same sockets by parent and child will result in I/O conflicts
195
+ such as `SocketError`, `Errno::EPIPE`, and `EOFError`.
196
+ 2. Background Ruby threads, including threads used by various third-party gems for connection
197
+ monitoring, etc., are **not** copied to the child process. Often this does not cause
198
+ immediate problems until a third-party connection goes down, at which point there will
199
+ be no supervisor to reconnect it.
200
+
201
+ Therefore, we recommend the following:
202
+
203
+ 1. If possible, do not establish any socket connections (HTTP, database connections, etc.)
204
+ inside Puma's master process when booting.
205
+ 2. If (1) is not possible, use `before_fork` and `before_refork` to disconnect the parent's socket
206
+ connections when forking, so that they are not accidentally copied to the child process.
207
+ 3. Use `before_worker_boot` to restart any background threads on the forked child.
208
+ 4. Use `after_refork` to restart any background threads on the parent.
209
+
210
+ #### Master process lifecycle hooks
211
+
212
+ Puma's configuration DSL provides master process lifecycle hooks `after_booted`, `before_restart`, and `after_stopped`
213
+ which may be used to specify code blocks to run on each event:
214
+
215
+ ```ruby
216
+ # config/puma.rb
217
+ after_booted do
218
+ # Add code to run in the Puma master process after it boots,
219
+ # and also after a phased restart completes.
220
+ end
221
+
222
+ before_restart do
223
+ # Add code to run in the Puma master process when it receives
224
+ # a restart command but before it restarts.
225
+ end
226
+
227
+ after_stopped do
228
+ # Add code to run in the Puma master process when it receives
229
+ # a stop command but before it shuts down.
230
+ end
231
+ ```
232
+
233
+ ### Error handling
234
+
235
+ If Puma encounters an error outside of the context of your application, it will respond with a 400/500 and a simple
236
+ textual error message (see `Puma::Server#lowlevel_error` or [server.rb](https://github.com/puma/puma/blob/main/lib/puma/server.rb)).
237
+ You can specify custom behavior for this scenario. For example, you can report the error to your third-party
238
+ error-tracking service (in this example, [rollbar](https://rollbar.com)):
239
+
240
+ ```ruby
241
+ lowlevel_error_handler do |e, env, status|
242
+ if status == 400
243
+ message = "The server could not process the request due to an error, such as an incorrectly typed URL, malformed syntax, or a URL that contains illegal characters.\n"
244
+ else
245
+ message = "An error has occurred, and engineers have been informed. Please reload the page. If you continue to have problems, contact support@example.com\n"
246
+ Rollbar.critical(e)
247
+ end
248
+
249
+ [status, {}, [message]]
250
+ end
251
+ ```
252
+
253
+ ### Binding TCP / Sockets
254
+
255
+ Bind Puma to a socket with the `-b` (or `--bind`) flag:
256
+
257
+ ```
258
+ $ puma -b tcp://127.0.0.1:9292
259
+ ```
260
+
261
+ To use a UNIX Socket instead of TCP:
262
+
263
+ ```
264
+ $ puma -b unix:///var/run/puma.sock
265
+ ```
266
+
267
+ If you need to change the permissions of the UNIX socket, just add a umask parameter:
268
+
269
+ ```
270
+ $ puma -b 'unix:///var/run/puma.sock?umask=0111'
271
+ ```
272
+
273
+ Need a bit of security? Use SSL sockets:
274
+
275
+ ```
276
+ $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
277
+ ```
278
+ #### Self-signed SSL certificates (via the [`localhost`] gem, for development use):
279
+
280
+ Puma supports the [`localhost`] gem for self-signed certificates. This is particularly useful if you want to use Puma with SSL locally, and self-signed certificates will work for your use-case. Currently, the integration can only be used in MRI.
281
+
282
+ Puma automatically configures SSL when the [`localhost`] gem is loaded in a `development` environment:
283
+
284
+ Add the gem to your Gemfile:
285
+ ```ruby
286
+ group(:development) do
287
+ gem 'localhost'
288
+ end
289
+ ```
290
+
291
+ And require it implicitly using bundler:
292
+ ```ruby
293
+ require "bundler"
294
+ Bundler.require(:default, ENV["RACK_ENV"].to_sym)
295
+ ```
296
+
297
+ Alternatively, you can require the gem in your configuration file, either `config/puma/development.rb`, `config/puma.rb`, or set via the `-C` cli option:
298
+ ```ruby
299
+ require 'localhost'
300
+ # configuration methods (from Puma::DSL) as needed
301
+ ```
302
+
303
+ Additionally, Puma must be listening to an SSL socket:
304
+
305
+ ```shell
306
+ $ puma -b 'ssl://localhost:9292' -C config/use_local_host.rb
307
+
308
+ # The following options allow you to reach Puma over HTTP as well:
309
+ $ puma -b ssl://localhost:9292 -b tcp://localhost:9393 -C config/use_local_host.rb
310
+ ```
311
+
312
+ [`localhost`]: https://github.com/socketry/localhost
313
+
314
+ #### Controlling SSL Cipher Suites
315
+
316
+ To use or avoid specific SSL ciphers for TLSv1.2 and below, use `ssl_cipher_filter` or `ssl_cipher_list` options.
317
+
318
+ ##### Ruby:
319
+
320
+ ```
321
+ $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&ssl_cipher_filter=!aNULL:AES+SHA'
322
+ ```
323
+
324
+ ##### JRuby:
325
+
326
+ ```
327
+ $ puma -b 'ssl://127.0.0.1:9292?keystore=path_to_keystore&keystore-pass=keystore_password&ssl_cipher_list=TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA'
328
+ ```
329
+
330
+ To configure the available TLSv1.3 ciphersuites, use `ssl_ciphersuites` option (not available for JRuby).
331
+
332
+ ##### Ruby:
333
+
334
+ ```
335
+ $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&ssl_ciphersuites=TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256'
336
+ ```
337
+
338
+ See https://www.openssl.org/docs/man1.1.1/man1/ciphers.html for cipher filter format and full list of cipher suites.
339
+
340
+ Disable TLS v1 with the `no_tlsv1` option:
341
+
342
+ ```
343
+ $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&no_tlsv1=true'
344
+ ```
345
+
346
+ #### Controlling OpenSSL Verification Flags
347
+
348
+ To enable verification flags offered by OpenSSL, use `verification_flags` (not available for JRuby):
349
+
350
+ ```
351
+ $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&verification_flags=PARTIAL_CHAIN'
352
+ ```
353
+
354
+ You can also set multiple verification flags (by separating them with a comma):
355
+
356
+ ```
357
+ $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&verification_flags=PARTIAL_CHAIN,CRL_CHECK'
358
+ ```
359
+
360
+ List of available flags: `USE_CHECK_TIME`, `CRL_CHECK`, `CRL_CHECK_ALL`, `IGNORE_CRITICAL`, `X509_STRICT`, `ALLOW_PROXY_CERTS`, `POLICY_CHECK`, `EXPLICIT_POLICY`, `INHIBIT_ANY`, `INHIBIT_MAP`, `NOTIFY_POLICY`, `EXTENDED_CRL_SUPPORT`, `USE_DELTAS`, `CHECK_SS_SIGNATURE`, `TRUSTED_FIRST`, `SUITEB_128_LOS_ONLY`, `SUITEB_192_LOS`, `SUITEB_128_LOS`, `PARTIAL_CHAIN`, `NO_ALT_CHAINS`, `NO_CHECK_TIME`
361
+ (see https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_hostflags.html#VERIFICATION-FLAGS).
362
+
363
+ #### Controlling OpenSSL Password Decryption
364
+
365
+ To enable runtime decryption of an encrypted SSL key (not available for JRuby), use `key_password_command`:
366
+
367
+ ```
368
+ $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&key_password_command=/path/to/command.sh'
369
+ ```
370
+
371
+ `key_password_command` must:
372
+
373
+ 1. Be executable by Puma.
374
+ 2. Print the decryption password to stdout.
375
+
376
+ For example:
377
+
378
+ ```shell
379
+ #!/bin/sh
380
+
381
+ echo "this is my password"
382
+ ```
383
+
384
+ `key_password_command` can be used with `key` or `key_pem`. If the key
385
+ is not encrypted, the executable will not be called.
386
+
387
+ ### Control/Status Server
388
+
389
+ Puma has a built-in status and control app that can be used to query and control Puma.
390
+
391
+ ```
392
+ $ puma --control-url tcp://127.0.0.1:9293 --control-token foo
393
+ ```
394
+
395
+ Puma will start the control server on localhost port 9293. All requests to the control server will need to include control token (in this case, `token=foo`) as a query parameter. This allows for simple authentication. Check out `Puma::App::Status` or [status.rb](https://github.com/puma/puma/blob/main/lib/puma/app/status.rb) to see what the status app has available.
396
+
397
+ You can also interact with the control server via `pumactl`. This command will restart Puma:
398
+
399
+ ```
400
+ $ pumactl --control-url 'tcp://127.0.0.1:9293' --control-token foo restart
401
+ ```
402
+
403
+ To see a list of `pumactl` options, use `pumactl --help`.
404
+
405
+ ### Configuration File
406
+
407
+ You can also provide a configuration file with the `-C` (or `--config`) flag:
408
+
409
+ ```
410
+ $ puma -C /path/to/config
411
+ ```
412
+
413
+ If no configuration file is specified, Puma will look for a configuration file at `config/puma.rb`. If an environment is specified (via the `--environment` flag or through the `APP_ENV`, `RACK_ENV`, or `RAILS_ENV` environment variables) Puma looks for a configuration file at `config/puma/<environment_name>.rb` and then falls back to `config/puma.rb`.
414
+
415
+ If you want to prevent Puma from looking for a configuration file in those locations, include the `--no-config` flag:
416
+
417
+ ```
418
+ $ puma --no-config
419
+
420
+ # or
421
+
422
+ $ puma -C "-"
423
+ ```
424
+
425
+ The other side-effects of setting the environment are whether to show stack traces (in `development` or `test`), and setting RACK_ENV may potentially affect middleware looking for this value to change their behavior. The default puma RACK_ENV value is `development`. You can see all config default values in `Puma::Configuration#puma_default_options` or [configuration.rb](https://github.com/puma/puma/blob/61c6213fbab/lib/puma/configuration.rb#L182-L204).
426
+
427
+ Check out `Puma::DSL` or [dsl.rb](https://github.com/puma/puma/blob/main/lib/puma/dsl.rb) to see all available options.
428
+
429
+ ## Restart
430
+
431
+ Puma includes the ability to restart itself. When available (MRI, Rubinius, JRuby), Puma performs a "hot restart". This is the same functionality available in *Unicorn* and *NGINX* which keep the server sockets open between restarts. This makes sure that no pending requests are dropped while the restart is taking place.
432
+
433
+ For more, see the [Restart documentation](docs/restart.md).
434
+
435
+ ## Signals
436
+
437
+ Puma responds to several signals. A detailed guide to using UNIX signals with Puma can be found in the [Signals documentation](docs/signals.md).
438
+
439
+ ## Platform Constraints
440
+
441
+ Some platforms do not support all Puma features.
442
+
443
+ * **JRuby**, **Windows**: server sockets are not seamless on restart, they must be closed and reopened. These platforms have no way to pass descriptors into a new process that is exposed to Ruby. Also, cluster mode is not supported due to a lack of fork(2).
444
+ * **Windows**: Cluster mode is not supported due to a lack of fork(2).
445
+ * **Kubernetes**: The way Kubernetes handles pod shutdowns interacts poorly with server processes implementing graceful shutdown, like Puma. See the [kubernetes section of the documentation](docs/kubernetes.md) for more details.
446
+
447
+ ## Deployment
448
+
449
+ * Puma has support for Capistrano with an [external gem](https://github.com/seuros/capistrano-puma).
450
+
451
+ * Additionally, Puma has support for built-in daemonization via the [puma-daemon](https://github.com/kigster/puma-daemon) ruby gem. The gem restores the `daemonize` option that was removed from Puma starting version 5, but only for MRI Ruby.
452
+
453
+
454
+ It is common to use process monitors with Puma. Modern process monitors like systemd or rc.d
455
+ provide continuous monitoring and restarts for increased reliability in production environments:
456
+
457
+ * [rc.d](docs/jungle/rc.d/README.md)
458
+ * [systemd](docs/systemd.md)
459
+
460
+ Community guides:
461
+
462
+ * [Deploying Puma on OpenBSD using relayd and httpd](https://gist.github.com/anon987654321/4532cf8d6c59c1f43ec8973faa031103)
463
+
464
+ ## Community Extensions
465
+
466
+ ### Plugins
467
+
468
+ * [puma-metrics](https://github.com/harmjanblok/puma-metrics) — export Puma metrics to Prometheus
469
+ * [puma-plugin-statsd](https://github.com/yob/puma-plugin-statsd) — send Puma metrics to statsd
470
+ * [puma-plugin-systemd](https://github.com/sj26/puma-plugin-systemd) — deeper integration with systemd for notify, status and watchdog. Puma 5.1.0 integrated notify and watchdog, which probably conflicts with this plugin. Puma 6.1.0 added status support which obsoletes the plugin entirely.
471
+ * [puma-plugin-telemetry](https://github.com/babbel/puma-plugin-telemetry) - telemetry plugin for Puma offering various targets to publish
472
+ * [puma-acme](https://github.com/anchordotdev/puma-acme) - automatic SSL/HTTPS certificate provisioning and setup
473
+
474
+ ### Monitoring
475
+
476
+ * [puma-status](https://github.com/ylecuyer/puma-status) — Monitor CPU/Mem/Load of running puma instances from the CLI
477
+
478
+ ## Contributing
479
+
480
+ Find details for contributing in the [contribution guide](CONTRIBUTING.md).
481
+
482
+ ## License
483
+
484
+ Puma is copyright Evan Phoenix and contributors, licensed under the BSD 3-Clause license. See the included LICENSE file for details.
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (c) 2011 Evan Phoenix
4
+ #
5
+
6
+ require 'puma/cli'
7
+
8
+ cli = Puma::CLI.new ARGV
9
+
10
+ cli.run
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (c) 2014 Evan Phoenix
4
+ #
5
+
6
+ require 'rubygems'
7
+
8
+ cli_arg = ARGV.shift
9
+
10
+ inc = ""
11
+
12
+ if cli_arg == "-I"
13
+ inc = ARGV.shift
14
+ $LOAD_PATH.concat inc.split(":")
15
+ end
16
+
17
+ module Puma; end
18
+
19
+ Puma.const_set(:WILD_ARGS, ["-I", inc])
20
+
21
+ require 'puma/cli'
22
+
23
+ cli = Puma::CLI.new ARGV
24
+
25
+ cli.run
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'puma/control_cli'
4
+
5
+ cli = Puma::ControlCLI.new ARGV.dup
6
+
7
+ begin
8
+ cli.run
9
+ rescue => e
10
+ STDERR.puts e.message
11
+ exit 1
12
+ end
@@ -0,0 +1,98 @@
1
+ # Welcome to Puma 5: Spoony Bard.
2
+
3
+ ![Spoony Bard](https://i1.kym-cdn.com/entries/icons/original/000/006/385/Spoony_Bard.jpg "Spoony Bard")
4
+
5
+ >Note: Puma 5 now automatically uses `WEB_CONCURRENCY` env var if set see [this post for an explanation](https://github.com/puma/puma/issues/2393#issuecomment-702352208). If your memory use goes up after upgrading to Puma 5 it indicates you're now running with multiple workers (processes). You can decrease memory use by tuning this number to be lower.
6
+
7
+ Puma 5 brings new experimental performance features, a few quality-of-life features and loads of bugfixes. Here's what you should do:
8
+
9
+ 1. Review the Upgrade section below to see if any of 5.0's breaking changes will affect you.
10
+ 2. Upgrade to version 5.0 in your Gemfile and deploy.
11
+ 3. Try the new performance experiments outlined below and report your results back to the Puma issue tracker.
12
+
13
+ Puma 5 was named Spoony Bard by our newest supercontributor, [@wjordan](https://github.com/puma/puma/commits?author=wjordan). Will brought you one of our new perf features for this release, as well as [many other fixes and refactors.](https://github.com/puma/puma/commits?author=wjordan) If you'd like to name a Puma release in the future, take a look at [CONTRIBUTING.md](../CONTRIBUTING.md) and get started helping us out :)
14
+
15
+ Puma 5 also welcomes [@MSP-Greg](https://github.com/puma/puma/commits?author=MSP-Greg) as our newest committer. Greg has been instrumental in improving our CI setup and SSL features. Greg also [named our 4.3.0 release](https://github.com/puma/puma/releases/tag/v4.3.0): Mysterious Traveller.
16
+
17
+ ## What's New
18
+
19
+ Puma 5 contains three new "experimental" performance features for cluster-mode Pumas running on MRI.
20
+
21
+ If you try any of these features, please report your results to [our report issue](https://github.com/puma/puma/issues/2258).
22
+
23
+ Part of the reason we're calling them _experimental_ is because we're not sure if they'll actually have any benefit. People's workloads in the real world are often not what we anticipate, and synthetic benchmarks are usually not of any help in figuring out if a change will be beneficial or not.
24
+
25
+ We do not believe any of the new features will have a negative effect or impact the stability of your application. This is either a "it works" or "it does nothing" experiment.
26
+
27
+ If any of the features turn out to be particularly beneficial, we may make them defaults in future versions of Puma.
28
+
29
+ ### Lower latency, better throughput
30
+
31
+ From our friends at GitLab, the new experimental `wait_for_less_busy_worker` config option may reduce latency and improve throughput for high-load Puma apps on MRI. See the [pull request](https://github.com/puma/puma/pull/2079) for more discussion.
32
+
33
+ Users of this option should see reduced request queue latency and possibly less overall latency.
34
+
35
+ Add the following to your `puma.rb` to try it:
36
+
37
+ ```ruby
38
+ wait_for_less_busy_worker
39
+ # or
40
+ wait_for_less_busy_worker 0.001
41
+ ```
42
+
43
+ Production testing at GitLab suggests values between `0.001` and `0.010` are best.
44
+
45
+ ### Better memory usage
46
+
47
+ 5.0 brings two new options to your config which may improve memory usage.
48
+
49
+ #### nakayoshi_fork
50
+
51
+ `nakayoshi_fork` calls GC a handful of times and compacts the heap on Ruby 2.7+ before forking. This may reduce memory usage of Puma on MRI with preload enabled. It's inspired by [Koichi Sasada's work](https://github.com/ko1/nakayoshi_fork).
52
+
53
+ To use it, you can add this to your `puma.rb`:
54
+
55
+ ```ruby
56
+ nakayoshi_fork
57
+ ```
58
+
59
+ #### fork_worker
60
+
61
+ Puma 5 introduces an experimental new cluster-mode configuration option, `fork_worker` (`--fork-worker` from the CLI). This mode causes Puma to fork additional workers from worker 0, instead of directly from the master process:
62
+
63
+ ```
64
+ 10000 \_ puma 4.3.3 (tcp://0.0.0.0:9292) [puma]
65
+ 10001 \_ puma: cluster worker 0: 10000 [puma]
66
+ 10002 \_ puma: cluster worker 1: 10000 [puma]
67
+ 10003 \_ puma: cluster worker 2: 10000 [puma]
68
+ 10004 \_ puma: cluster worker 3: 10000 [puma]
69
+ ```
70
+
71
+ It is compatible with phased restarts. It also may improve memory usage because the worker process loads additional code after processing requests.
72
+
73
+ To learn more about using `refork` and `fork_worker`, see ['Fork Worker'](fork_worker.md).
74
+
75
+ ### What else is new?
76
+
77
+ * **Loads of bugfixes**.
78
+ * Faster phased restarts and worker timeouts.
79
+ * pumactl now has a `thread-backtraces` command to print thread backtraces, bringing thread backtrace printing to all platforms, not just *BSD and Mac. (#2053)
80
+ * Added incrementing `requests_count` to `Puma.stats`. (#2106)
81
+ * Faster phased restart and worker timeout. (#2220)
82
+ * Added `state_permission` to config DSL to set state file permissions (#2238)
83
+ * Ruby 2.2 support will be dropped in Puma 6. This is the final major release series for Ruby 2.2.
84
+
85
+ ## Upgrade
86
+
87
+ * Setting the `WEB_CONCURRENCY` environment variable will now configure the number of workers (processes) that Puma will boot and enable preloading of the application.
88
+ * If you did not explicitly set `environment` before, Puma now checks `RAILS_ENV` and will use that, if available in addition to `RACK_ENV`.
89
+ * If you have been using the `--control` CLI option, update your scripts to use `--control-url`.
90
+ * If you are using `worker_directory` in your config file, change it to `directory`.
91
+ * If you are running MRI, default thread count on Puma is now 5, not 16. This may change the amount of threads running in your threadpool. We believe 5 is a better default for most Ruby web applications on MRI. Higher settings increase latency by causing GVL contention.
92
+ * If you are using a worker count of more than 1, set using `WEB_CONCURRENCY`, Puma will now preload the application by default (disable with `preload_app! false`). We believe this is a better default, but may cause issues in non-Rails applications if you do not have the proper `before` and `after` fork hooks configured. See documentation for your framework. Rails users do not need to change anything. **Please note that it is not possible to use [the phased restart](restart.md) with preloading.**
93
+ * tcp mode and daemonization have been removed without replacement. For daemonization, please use a modern process management solution, such as systemd or monit.
94
+ * `connected_port` was renamed to `connected_ports` and now returns an Array, not an Integer.
95
+
96
+ Then, update your Gemfile:
97
+
98
+ `gem 'puma', '< 6'`