puma 6.6.0 → 7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94e6b5d56525a92e2e279d59467572a254c7c03b9dc14a3e91ec5eba67b54620
4
- data.tar.gz: 55e78ab10a5d222cce09dc89a92fbbd15d8e8ae7abbec95ca309e2903f68bd97
3
+ metadata.gz: 8e662aa9214837e2d08713550a828fe7ae8bdefe1eac79c9def581a6e089745b
4
+ data.tar.gz: 70dab329bbcf71e4ae4da042591eb8311de4c729e3c8d334d7c0ddc20bcf7aa4
5
5
  SHA512:
6
- metadata.gz: 750f9ec059b9710eb5ae739dc04ad600fff8386a40dc3ef83500189caacf8b7413d01eb60d751befd1aa077f3565e60617d13ceba8b9a0c29912abf410b700ff
7
- data.tar.gz: 1a56b1696333ae86e643bd045ebe83f6a1700ac5df948113a443326e867ce17bf3f4b7e05e01cda6b99605130a2b77ccf49d2ae153ad2e879971c7238d652548
6
+ metadata.gz: 379e3b2c89c03169805ec2c67e4ab43bb9af1a32d23a8f5f58dc0fc3d958ca34bdcc7390d656613357a5dbb86c1f8fa9b403d40e95cecb518a4c7b2415e65a05
7
+ data.tar.gz: 2981fa2d413989754a70c0c3a2df62a0efbcb8529b66cf78d6df917751d220bdd7b842ece6536ed789547b063b83498eb1c81bb37507e2289a8728929bfbcf34
data/History.md CHANGED
@@ -1,3 +1,72 @@
1
+ ## 7.0.1 / 2025-09-06
2
+
3
+ * Bugfixes
4
+ * Add backward compatibility aliases for Events class methods ([#3725])
5
+
6
+ ## 7.0.0 / 2025-09-03
7
+
8
+ * Breaking changes
9
+ * Set default `max_keep_alive` to 999 ([#3719])
10
+ * Increase `persistent_timeout` default to 65 seconds ([#3378])
11
+ * Raise an ArgumentError if no block given to hooks ([#3377])
12
+ * Don't set env['HTTP_VERSION'] for Rack > 3.1 ([#3711], [#3576])
13
+ * Runner.rb - remove `ruby_engine` method, deprecated Nov-2024 ([#3701])
14
+ * Set conditional config defaults after CLI options are parsed and config files are loaded ([#3297])
15
+ * Response headers set to lowercase ([#3704])
16
+ * Update minimum Ruby version to 3.0 ([#3698])
17
+ * Rename callback hooks ([#3438])
18
+
19
+ | Old hook name| New hook name|
20
+ |----------|----------|
21
+ | on_worker_boot | before_worker_boot |
22
+ | on_worker_shutdown | before_worker_shutdown |
23
+ | on_restart | before_restart |
24
+ | on_booted | after_booted |
25
+ | on_stopped | after_stopped |
26
+ | on_refork | before_refork |
27
+ | on_thread_start | before_thread_start |
28
+ | on_thread_exit | before_thread_exit |
29
+ | on_worker_fork | before_worker_fork |
30
+
31
+ * Features
32
+ * Fix long tail response problem with keepalive connections ([#3678]) (Previously released in 7.0.0.pre1, this was a high effort change)
33
+ * Introduce support for fiber-per-request. ([#3101])
34
+ * Add support for `rack.response_finished` ([#3681])
35
+ * Feature/support custom logger with request logs ([#3140])
36
+
37
+ * Bugfixes
38
+ * Fix error_logger inproperly logging `env[QUERY_STRING]` ([#3713], [#3625])
39
+ * Fix handling of invalid Transfer-Encoding header errors ([#3702])
40
+ * Fix socket leak on monitor wakeup `NoMethodError` in `Reactor#select_loop` ([#3696], [#3695])
41
+ * CI: puma_socket.rb fixup socket/request writes ([#3684])
42
+ * Warn when RUBY_MN_THREADS env var is set ([#3721])
43
+ * Improve the DSL `preload_app!` doc ([#3712])
44
+ * Fix the ability to focus individual tests ([#3705])
45
+ * Set env['rack.hijack'] to client.method(:full_hijack) ([#3073])
46
+
47
+ * Performance
48
+ * server.rb - initialize ivars `@reactor` and `@env_set_http_version` ([#3714])
49
+
50
+ * Refactor
51
+ * Simplify `Puma::DSL#process_hook` logic ([#3710])
52
+ * Dry up deprecation warnings and fix deprecation warnings when running CI. ([#3709], [#3708])
53
+ * Ensure and enforce that configs are loaded before options are accessed ([#3616])
54
+
55
+ ## 7.0.0.pre1 / 2025-07-31
56
+
57
+ * Changed
58
+ * Fix long tail response problem with keepalive connections ([#3678])
59
+
60
+ ## 6.6.1 / 2025-07-30
61
+
62
+ * Bugfixes
63
+ * Accept `to_path` to be `nil` on request bodies ([#3635])
64
+ * Fix single runner stats before the server start ([#3572])
65
+ * Fix incomplete worker boot state on refork ([#3601])
66
+ * Improve HttpParserError messages for better debugging ([#3586])
67
+ * Fix refork logs to distinguish from phased restarts ([#3598])
68
+ * Fix `rack.after_reply` so it doesn't interrupt chain on error ([#3680])
69
+
1
70
  ## 6.6.0 / 2025-01-29
2
71
 
3
72
  * Features
@@ -163,7 +232,7 @@
163
232
 
164
233
  * Features
165
234
  * Ability to supply a custom logger ([#2770], [#2511])
166
- * Warn when clustered-only hooks are defined in single mode ([#3089])
235
+ * Warn when cluster mode-only hooks are defined in single mode ([#3089])
167
236
  * Adds the on_booted event ([#2709])
168
237
 
169
238
  * Bugfixes
@@ -758,7 +827,7 @@ Each patchlevel release contains a separate security fix. We recommend simply up
758
827
  * Fix Java 8 support ([#1773])
759
828
  * Fix error `uninitialized constant Puma::Cluster` ([#1731])
760
829
  * Fix `not_token` being able to be set to true ([#1803])
761
- * Fix "Hang on SIGTERM with ruby 2.6 in clustered mode" (PR [#1741], [#1674], [#1720], [#1730], [#1755])
830
+ * Fix "Hang on SIGTERM with ruby 2.6 in cluster mode" (PR [#1741], [#1674], [#1720], [#1730], [#1755])
762
831
 
763
832
  ## 3.12.1 / 2019-03-19
764
833
 
@@ -1169,7 +1238,7 @@ Each patchlevel release contains a separate security fix. We recommend simply up
1169
1238
  * 4 minor features:
1170
1239
 
1171
1240
  * Listen to unix socket with provided backlog if any
1172
- * Improves the clustered stats to report worker stats
1241
+ * Improves the cluster mode stats to report worker stats
1173
1242
  * Pass the env to the lowlevel_error handler. Fixes [#854]
1174
1243
  * Treat path-like hosts as unix sockets. Fixes [#824]
1175
1244
 
@@ -1896,7 +1965,7 @@ The "clearly I don't have enough tests for the config" release.
1896
1965
 
1897
1966
  * 3 doc changes:
1898
1967
  * Add note about on_worker_boot hook
1899
- * Add some documentation for Clustered mode
1968
+ * Add some documentation for Cluster mode
1900
1969
  * Added quotes to /etc/puma.conf
1901
1970
 
1902
1971
  ## 2.0.1 / 2013-04-30
@@ -2150,6 +2219,42 @@ be added back in a future date when a java Puma::MiniSSL is added.
2150
2219
  * Bugfixes
2151
2220
  * Your bugfix goes here <Most recent on the top, like GitHub> (#Github Number)
2152
2221
 
2222
+ [#3725]:https://github.com/puma/puma/pull/3725 "PR by @tannakartikey, merged 2025-09-05"
2223
+ [#3719]:https://github.com/puma/puma/pull/3719 "PR by @schneems, merged 2025-09-03"
2224
+ [#3378]:https://github.com/puma/puma/pull/3378 "PR by @shayonj, merged 2025-08-19"
2225
+ [#3377]:https://github.com/puma/puma/pull/3377 "PR by @joshuay03, merged 2025-08-12"
2226
+ [#3711]:https://github.com/puma/puma/pull/3711 "PR by @MSP-Greg, merged 2025-08-28"
2227
+ [#3576]:https://github.com/puma/puma/issues/3576 "Issue by @pdalberti, closed 2025-08-28"
2228
+ [#3701]:https://github.com/puma/puma/pull/3701 "PR by @MSP-Greg, merged 2025-08-26"
2229
+ [#3297]:https://github.com/puma/puma/pull/3297 "PR by @joshuay03, merged 2025-08-26"
2230
+ [#3704]:https://github.com/puma/puma/pull/3704 "PR by @schneems, merged 2025-08-25"
2231
+ [#3698]:https://github.com/puma/puma/pull/3698 "PR by @schneems, merged 2025-08-21"
2232
+ [#3438]:https://github.com/puma/puma/pull/3438 "PR by @tannakartikey, merged 2025-08-25"
2233
+ [#3678]:https://github.com/puma/puma/pull/3678 "PR by @MSP-Greg, merged 2025-07-31"
2234
+ [#3101]:https://github.com/puma/puma/pull/3101 "PR by @ioquatix, merged 2025-08-25"
2235
+ [#3681]:https://github.com/puma/puma/pull/3681 "PR by @byroot, merged 2025-08-15"
2236
+ [#3140]:https://github.com/puma/puma/pull/3140 "PR by @phyzical, merged 2025-08-12"
2237
+ [#3713]:https://github.com/puma/puma/pull/3713 "PR by @MSP-Greg, merged 2025-08-29"
2238
+ [#3625]:https://github.com/puma/puma/pull/3625 "PR by @bhooshiek-narendiran, closed 2025-08-29"
2239
+ [#3702]:https://github.com/puma/puma/pull/3702 "PR by @marshall-lee, merged 2025-08-25"
2240
+ [#3696]:https://github.com/puma/puma/pull/3696 "PR by @joshuay03, merged 2025-08-22"
2241
+ [#3695]:https://github.com/puma/puma/issues/3695 "Issue by @joshuay03, closed 2025-08-22"
2242
+ [#3684]:https://github.com/puma/puma/pull/3684 "PR by @MSP-Greg, merged 2025-08-02"
2243
+ [#3721]:https://github.com/puma/puma/pull/3721 "PR by @schneems, merged 2025-09-03"
2244
+ [#3712]:https://github.com/puma/puma/pull/3712 "PR by @joshuay03, merged 2025-08-28"
2245
+ [#3705]:https://github.com/puma/puma/pull/3705 "PR by @schneems, merged 2025-08-25"
2246
+ [#3073]:https://github.com/puma/puma/pull/3073 "PR by @MSP-Greg, merged 2025-08-12"
2247
+ [#3714]:https://github.com/puma/puma/pull/3714 "PR by @MSP-Greg, merged 2025-08-29"
2248
+ [#3710]:https://github.com/puma/puma/pull/3710 "PR by @joshuay03, merged 2025-08-28"
2249
+ [#3709]:https://github.com/puma/puma/pull/3709 "PR by @MSP-Greg, merged 2025-08-28"
2250
+ [#3708]:https://github.com/puma/puma/issues/3708 "Issue by @schneems, closed 2025-08-28"
2251
+ [#3616]:https://github.com/puma/puma/pull/3616 "PR by @joshuay03, merged 2025-08-25"
2252
+ [#3635]:https://github.com/puma/puma/pull/3635 "PR by @LevitatingBusinessMan, merged 2025-05-08"
2253
+ [#3572]:https://github.com/puma/puma/pull/3572 "PR by @barthez, merged 2025-02-06"
2254
+ [#3601]:https://github.com/puma/puma/pull/3601 "PR by @joshuay03, merged 2025-01-31"
2255
+ [#3586]:https://github.com/puma/puma/pull/3586 "PR by @MSP-Greg, merged 2025-02-03"
2256
+ [#3598]:https://github.com/puma/puma/pull/3598 "PR by @joshuay03, merged 2025-01-31"
2257
+ [#3680]:https://github.com/puma/puma/pull/3680 "PR by @byroot, merged 2025-07-31"
2153
2258
  [#3570]:https://github.com/puma/puma/pull/3570 "PR by @mohamedhafez, merged 2024-12-30"
2154
2259
  [#3567]:https://github.com/puma/puma/issues/3567 "Issue by @mohamedhafez, closed 2024-12-30"
2155
2260
  [#3383]:https://github.com/puma/puma/pull/3383 "PR by @joshuay03, merged 2024-11-29"
@@ -2748,7 +2853,7 @@ be added back in a future date when a java Puma::MiniSSL is added.
2748
2853
  [#1022]:https://github.com/puma/puma/issues/1022 "Issue by @AKovtunov, closed 2017-08-16"
2749
2854
  [#958]:https://github.com/puma/puma/issues/958 "Issue by @lalitlogical, closed 2016-04-23"
2750
2855
  [#782]:https://github.com/puma/puma/issues/782 "Issue by @Tonkpils, closed 2016-07-19"
2751
- [#1010]:https://github.com/puma/puma/issues/1010 "Issue by @mneumark, closed 2016-07-19"
2856
+ [#1010]:https://github.com/puma/puma/issues/1010 "Issue by @mirineumark, closed 2016-07-19"
2752
2857
  [#959]:https://github.com/puma/puma/issues/959 "Issue by @mwpastore, closed 2016-04-22"
2753
2858
  [#840]:https://github.com/puma/puma/issues/840 "Issue by @marisawallace, closed 2016-04-07"
2754
2859
  [#1007]:https://github.com/puma/puma/pull/1007 "PR by @willnet, merged 2016-06-24"
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # Puma: A Ruby Web Server Built For Parallelism
6
6
 
7
- [![Actions](https://github.com/puma/puma/workflows/Tests/badge.svg?branch=master)](https://github.com/puma/puma/actions?query=workflow%3ATests)
7
+ [![Actions](https://github.com/puma/puma/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/puma/puma/actions/workflows/tests.yml?query=branch%3Amaster)
8
8
  [![Code Climate](https://codeclimate.com/github/puma/puma.svg)](https://codeclimate.com/github/puma/puma)
9
9
  [![StackOverflow](https://img.shields.io/badge/stackoverflow-Puma-blue.svg)]( https://stackoverflow.com/questions/tagged/puma )
10
10
 
@@ -102,9 +102,9 @@ Puma will automatically scale the number of threads, from the minimum until it c
102
102
 
103
103
  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.
104
104
 
105
- ### Clustered mode
105
+ ### Cluster mode
106
106
 
107
- Puma also offers "clustered mode". Clustered 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:
107
+ 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:
108
108
 
109
109
  ```
110
110
  $ puma -t 8:32 -w 3
@@ -116,15 +116,15 @@ Or with the `WEB_CONCURRENCY` environment variable:
116
116
  $ WEB_CONCURRENCY=3 puma -t 8:32
117
117
  ```
118
118
 
119
- Note that threads are still used in clustered 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.
119
+ 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.
120
120
 
121
121
  If 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://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent.html#available_processor_count-class_method).
122
122
 
123
123
  For an in-depth discussion of the tradeoffs of thread and process count settings, [see our docs](https://github.com/puma/puma/blob/9282a8efa5a0c48e39c60d22ca70051a25df9f55/docs/kubernetes.md#workers-per-pod-and-other-config-issues).
124
124
 
125
- In clustered 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).
125
+ 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).
126
126
 
127
- If the `WEB_CONCURRENCY` environment variable is set to a value > 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:
127
+ 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:
128
128
 
129
129
  ```
130
130
  $ puma -w 3 --preload
@@ -140,9 +140,9 @@ preload_app!
140
140
 
141
141
  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.
142
142
 
143
- #### Clustered mode hooks
143
+ #### Cluster mode hooks
144
144
 
145
- When using clustered mode, Puma's configuration DSL provides `before_fork` and `on_worker_boot`
145
+ When using clustered mode, Puma's configuration DSL provides `before_fork` and `before_worker_boot`
146
146
  hooks to run code when the master process forks and child workers are booted respectively.
147
147
 
148
148
  It is recommended to use these hooks with `preload_app!`, otherwise constants loaded by your
@@ -154,16 +154,16 @@ before_fork do
154
154
  # Add code to run inside the Puma master process before it forks a worker child.
155
155
  end
156
156
 
157
- on_worker_boot do
157
+ before_worker_boot do
158
158
  # Add code to run inside the Puma worker process after forking.
159
159
  end
160
160
  ```
161
161
 
162
- In addition, there is an `on_refork` and `after_refork` hooks which are used only in [`fork_worker` mode](docs/fork_worker.md),
162
+ In addition, there is an `before_refork` and `after_refork` hooks which are used only in [`fork_worker` mode](docs/fork_worker.md),
163
163
  when the worker 0 child process forks a grandchild worker:
164
164
 
165
165
  ```ruby
166
- on_refork do
166
+ before_refork do
167
167
  # Used only when fork_worker mode is enabled. Add code to run inside the Puma worker 0
168
168
  # child process before it forks a grandchild worker.
169
169
  end
@@ -176,7 +176,7 @@ after_refork do
176
176
  end
177
177
  ```
178
178
 
179
- Importantly, note the following considerations when Ruby forks a child process:
179
+ Importantly, note the following considerations when Ruby forks a child process:
180
180
 
181
181
  1. File descriptors such as network sockets **are** copied from the parent to the forked
182
182
  child process. Dual-use of the same sockets by parent and child will result in I/O conflicts
@@ -190,29 +190,29 @@ Therefore, we recommend the following:
190
190
 
191
191
  1. If possible, do not establish any socket connections (HTTP, database connections, etc.)
192
192
  inside Puma's master process when booting.
193
- 2. If (1) is not possible, use `before_fork` and `on_refork` to disconnect the parent's socket
193
+ 2. If (1) is not possible, use `before_fork` and `before_refork` to disconnect the parent's socket
194
194
  connections when forking, so that they are not accidentally copied to the child process.
195
- 3. Use `on_worker_boot` to restart any background threads on the forked child.
195
+ 3. Use `before_worker_boot` to restart any background threads on the forked child.
196
196
  4. Use `after_refork` to restart any background threads on the parent.
197
197
 
198
198
  #### Master process lifecycle hooks
199
199
 
200
- Puma's configuration DSL provides master process lifecycle hooks `on_booted`, `on_restart`, and `on_stopped`
200
+ Puma's configuration DSL provides master process lifecycle hooks `after_booted`, `before_restart`, and `after_stopped`
201
201
  which may be used to specify code blocks to run on each event:
202
202
 
203
203
  ```ruby
204
204
  # config/puma.rb
205
- on_booted do
205
+ after_booted do
206
206
  # Add code to run in the Puma master process after it boots,
207
207
  # and also after a phased restart completes.
208
208
  end
209
209
 
210
- on_restart do
210
+ before_restart do
211
211
  # Add code to run in the Puma master process when it receives
212
212
  # a restart command but before it restarts.
213
213
  end
214
214
 
215
- on_stopped do
215
+ after_stopped do
216
216
  # Add code to run in the Puma master process when it receives
217
217
  # a stop command but before it shuts down.
218
218
  end
@@ -432,19 +432,6 @@ Some platforms do not support all Puma features.
432
432
  * **Windows**: Cluster mode is not supported due to a lack of fork(2).
433
433
  * **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.
434
434
 
435
- ## Known Bugs
436
-
437
- For MRI versions 2.2.7, 2.2.8, 2.2.9, 2.2.10, 2.3.4 and 2.4.1, you may see ```stream closed in another thread (IOError)```. It may be caused by a [Ruby bug](https://bugs.ruby-lang.org/issues/13632). It can be fixed with the gem https://rubygems.org/gems/stopgap_13632:
438
-
439
- ```ruby
440
- if %w(2.2.7 2.2.8 2.2.9 2.2.10 2.3.4 2.4.1).include? RUBY_VERSION
441
- begin
442
- require 'stopgap_13632'
443
- rescue LoadError
444
- end
445
- end
446
- ```
447
-
448
435
  ## Deployment
449
436
 
450
437
  * Puma has support for Capistrano with an [external gem](https://github.com/seuros/capistrano-puma).
data/docs/fork_worker.md CHANGED
@@ -24,13 +24,13 @@ The `fork_worker` option allows your application to be initialized only once for
24
24
 
25
25
  ### Usage Considerations
26
26
 
27
- - `fork_worker` introduces new `on_refork` and `after_refork` configuration hooks. Note the following:
28
- - When initially forking the parent process to the worker 0 child, `before_fork` will trigger on the parent process and `on_worker_boot` will trigger on the worker 0 child as normal.
29
- - When forking the worker 0 child to grandchild workers, `on_refork` and `after_refork` will trigger on the worker 0 child, and `on_worker_boot` will trigger on each grandchild worker.
27
+ - `fork_worker` introduces new `before_refork` and `after_refork` configuration hooks. Note the following:
28
+ - When initially forking the parent process to the worker 0 child, `before_fork` will trigger on the parent process and `before_worker_boot` will trigger on the worker 0 child as normal.
29
+ - When forking the worker 0 child to grandchild workers, `before_refork` and `after_refork` will trigger on the worker 0 child, and `before_worker_boot` will trigger on each grandchild worker.
30
30
  - For clarity, `before_fork` does not trigger on worker 0, and `after_refork` does not trigger on the grandchild.
31
31
  - As a general migration guide:
32
- - Copy any logic within your existing `before_fork` hook to the `on_refork` hook.
33
- - Consider to copy logic from your `on_worker_boot` hook to the `after_refork` hook, if it is needed to reset the state of worker 0 after it forks.
32
+ - Copy any logic within your existing `before_fork` hook to the `before_refork` hook.
33
+ - Consider to copy logic from your `before_worker_boot` hook to the `after_refork` hook, if it is needed to reset the state of worker 0 after it forks.
34
34
 
35
35
  ### Limitations
36
36
 
data/docs/kubernetes.md CHANGED
@@ -8,10 +8,11 @@ In general running Puma in Kubernetes works as-is, no special configuration is n
8
8
 
9
9
  Assuming you already have a running cluster and docker image repository, you can run a simple Puma app with the following example Dockerfile and Deployment specification. These are meant as examples only and are deliberately very minimal to the point of skipping many options that are recommended for running in production, like healthchecks and envvar configuration with ConfigMaps. In general you should check the [Kubernetes documentation](https://kubernetes.io/docs/home/) and [Docker documentation](https://docs.docker.com/) for a more comprehensive overview of the available options.
10
10
 
11
- A basic Dockerfile example:
11
+ A basic Dockerfile example:
12
+
12
13
  ```
13
- FROM ruby:2.5.1-alpine # can be updated to newer ruby versions
14
- RUN apk update && apk add build-base # and any other packages you need
14
+ FROM ruby:3.4.5-alpine # can be updated to newer ruby versions
15
+ RUN apk update && apk add build-base # and any other packages you need
15
16
 
16
17
  # Only rebuild gem bundle if Gemfile changes
17
18
  COPY Gemfile Gemfile.lock ./
@@ -26,6 +27,7 @@ CMD bundle exec rackup -o 0.0.0.0
26
27
  ```
27
28
 
28
29
  A sample `deployment.yaml`:
30
+
29
31
  ```
30
32
  ---
31
33
  apiVersion: apps/v1
@@ -47,7 +49,7 @@ spec:
47
49
  image: <your image here>
48
50
  ports:
49
51
  - containerPort: 9292
50
- ```
52
+ ```
51
53
 
52
54
  ## Graceful shutdown and pod termination
53
55
 
data/docs/restart.md CHANGED
@@ -29,7 +29,7 @@ Any of the following will cause a Puma server to perform a hot restart:
29
29
 
30
30
  * The newly started Puma process changes its current working directory to the directory specified by the `directory` option. If `directory` is set to symlink, this is automatically re-evaluated, so this mechanism can be used to upgrade the application.
31
31
  * Only one version of the application is running at a time.
32
- * `on_restart` is invoked just before the server shuts down. This can be used to clean up resources (like long-lived database connections) gracefully. Since Ruby 2.0, it is not typically necessary to explicitly close file descriptors on restart. This is because any file descriptor opened by Ruby will have the `FD_CLOEXEC` flag set, meaning that file descriptors are closed on `exec`. `on_restart` is useful, though, if your application needs to perform any more graceful protocol-specific shutdown procedures before closing connections.
32
+ * `before_restart` is invoked just before the server shuts down. This can be used to clean up resources (like long-lived database connections) gracefully. Since Ruby 2.0, it is not typically necessary to explicitly close file descriptors on restart. This is because any file descriptor opened by Ruby will have the `FD_CLOEXEC` flag set, meaning that file descriptors are closed on `exec`. `before_restart` is useful, though, if your application needs to perform any more graceful protocol-specific shutdown procedures before closing connections.
33
33
 
34
34
  ## Phased restart
35
35
 
@@ -59,7 +59,7 @@ Any of the following will cause a Puma server to perform a phased restart:
59
59
 
60
60
  * When a phased restart begins, the Puma master process changes its current working directory to the directory specified by the `directory` option. If `directory` is set to symlink, this is automatically re-evaluated, so this mechanism can be used to upgrade the application.
61
61
  * On a single server, it's possible that two versions of the application are running concurrently during a phased restart.
62
- * `on_restart` is not invoked
62
+ * `before_restart` is not invoked
63
63
  * Phased restarts can be slow for Puma clusters with many workers. Hot restarts often complete more quickly, but at the cost of increased latency during the restart.
64
64
  * Phased restarts cannot be used to upgrade any gems loaded by the Puma master process, including `puma` itself, anything in `extra_runtime_dependencies`, or dependencies thereof. Upgrading other gems is safe.
65
65
  * If you remove the gems from old releases as part of your deployment strategy, there are additional considerations. Do not put any gems into `extra_runtime_dependencies` that have native extensions or have dependencies that have native extensions (one common example is `puma_worker_killer` and its dependency on `ffi`). Workers will fail on boot during a phased restart. The underlying issue is recorded in [an issue on the rubygems project](https://github.com/rubygems/rubygems/issues/4004). Hot restarts are your only option here if you need these dependencies.
data/docs/signals.md CHANGED
@@ -17,13 +17,13 @@ $ ps aux | grep tail
17
17
  schneems 87152 0.0 0.0 2432772 492 s032 S+ 12:46PM 0:00.00 tail -f my.log
18
18
  ```
19
19
 
20
- You can send a signal in Ruby using the [Process module](https://ruby-doc.org/3.2.2/Process.html#method-c-kill):
20
+ You can send a signal in Ruby using the [Process module](https://docs.ruby-lang.org/en/master/Process.html#method-c-kill):
21
21
 
22
22
  ```
23
23
  $ irb
24
24
  > puts pid
25
25
  => 87152
26
- Process.detach(pid) # https://ruby-doc.org/3.2.2/Process.html#method-c-detach
26
+ Process.detach(pid) # https://docs.ruby-lang.org/en/master/Process.html#method-c-detach
27
27
  Process.kill("TERM", pid)
28
28
  ```
29
29
 
@@ -54,12 +54,12 @@ puma configuration file reloaded, if there is one
54
54
  puma configuration file reloaded, if there is one
55
55
 
56
56
  before_fork
57
- on_worker_fork
57
+ before_worker_fork
58
58
  after_worker_fork
59
59
 
60
60
  Gemfile in context
61
61
 
62
- on_worker_boot
62
+ before_worker_boot
63
63
 
64
64
  Code of the app is loaded and running
65
65
  ```
@@ -67,18 +67,18 @@ Code of the app is loaded and running
67
67
  ### Send USR2
68
68
 
69
69
  ```
70
- on_worker_shutdown
71
- on_restart
70
+ before_worker_shutdown
71
+ before_restart
72
72
 
73
73
  puma configuration file reloaded, if there is one
74
74
 
75
75
  before_fork
76
- on_worker_fork
76
+ before_worker_fork
77
77
  after_worker_fork
78
78
 
79
79
  Gemfile in context
80
80
 
81
- on_worker_boot
81
+ before_worker_boot
82
82
 
83
83
  Code of the app is loaded and running
84
84
  ```
@@ -86,13 +86,13 @@ Code of the app is loaded and running
86
86
  ### Send USR1
87
87
 
88
88
  ```
89
- on_worker_shutdown
90
- on_worker_fork
89
+ before_worker_shutdown
90
+ before_worker_fork
91
91
  after_worker_fork
92
92
 
93
93
  Gemfile in context
94
94
 
95
- on_worker_boot
95
+ before_worker_boot
96
96
 
97
97
  Code of the app is loaded and running
98
98
  ```
data/docs/stats.md CHANGED
@@ -65,7 +65,8 @@ When Puma runs in single mode, these stats are available at the top level. When
65
65
  and is not used for any internal decisions, unlike `busy_theads`, which is usually a more useful stat.
66
66
  * max_threads: the maximum number of threads Puma is configured to spool per worker
67
67
  * requests_count: the number of requests this worker has served since starting
68
-
68
+ * reactor_max: the maximum observed number of requests held in Puma's "reactor" which is used for asyncronously buffering request bodies. This stat is reset on every call, so it's the maximum value observed since the last stat call.
69
+ * backlog_max: the maximum number of requests that have been fully buffered by the reactor and placed in a ready queue, but have not yet been picked up by a server thread. This stat is reset on every call, so it's the maximum value observed since the last stat call.
69
70
 
70
71
  ### cluster mode
71
72
 
data/docs/systemd.md CHANGED
@@ -72,7 +72,7 @@ systemd and Puma also support socket activation, where systemd opens the
72
72
  listening socket(s) in advance and provides them to the Puma master process on
73
73
  startup. Among other advantages, this keeps listening sockets open across puma
74
74
  restarts and achieves graceful restarts, including when upgraded Puma, and is
75
- compatible with both clustered mode and application preload.
75
+ compatible with both cluster mode and application preload.
76
76
 
77
77
  **Note:** Any wrapper scripts which `exec`, or other indirections in `ExecStart`
78
78
  may result in activated socket file descriptors being closed before reaching the
@@ -52,29 +52,14 @@ unless ENV["PUMA_DISABLE_SSL"]
52
52
  have_func "SSL_get1_peer_certificate" , ssl_h
53
53
 
54
54
  puts ''
55
-
56
- # Random.bytes available in Ruby 2.5 and later, Random::DEFAULT deprecated in 3.0
57
- if Random.respond_to?(:bytes)
58
- $defs.push "-DHAVE_RANDOM_BYTES"
59
- puts "checking for Random.bytes... yes"
60
- else
61
- puts "checking for Random.bytes... no"
62
- end
63
55
  end
64
56
  end
65
57
 
66
58
  if ENV["PUMA_MAKE_WARNINGS_INTO_ERRORS"]
67
59
  # Make all warnings into errors
68
60
  # Except `implicit-fallthrough` since most failures comes from ragel state machine generated code
69
- if respond_to?(:append_cflags, true) # Ruby 2.5 and later
70
- append_cflags(config_string('WERRORFLAG') || '-Werror')
71
- append_cflags '-Wno-implicit-fallthrough'
72
- else
73
- # flag may not exist on some platforms, -Werror may not be defined on some platforms, but
74
- # works with all in current CI
75
- $CFLAGS << " #{config_string('WERRORFLAG') || '-Werror'}"
76
- $CFLAGS << ' -Wno-implicit-fallthrough'
77
- end
61
+ append_cflags(config_string('WERRORFLAG') || '-Werror')
62
+ append_cflags '-Wno-implicit-fallthrough'
78
63
  end
79
64
 
80
65
  create_makefile("puma/puma_http11")
@@ -471,13 +471,8 @@ sslctx_initialize(VALUE self, VALUE mini_ssl_ctx) {
471
471
  SSL_CTX_set_verify(ctx, NUM2INT(verify_mode), engine_verify_callback);
472
472
  }
473
473
 
474
- // Random.bytes available in Ruby 2.5 and later, Random::DEFAULT deprecated in 3.0
475
474
  session_id_bytes = rb_funcall(
476
- #ifdef HAVE_RANDOM_BYTES
477
475
  rb_cRandom,
478
- #else
479
- rb_const_get(rb_cRandom, rb_intern_const("DEFAULT")),
480
- #endif
481
476
  rb_intern_const("bytes"),
482
477
  1, ULL2NUM(SSL_MAX_SSL_SESSION_ID_LENGTH));
483
478
 
@@ -29,7 +29,7 @@ public class Http11 extends RubyObject {
29
29
  public final static int MAX_REQUEST_URI_LENGTH = getConstLength("PUMA_REQUEST_URI_MAX_LENGTH", 1024 * 12);
30
30
  public final static String MAX_REQUEST_URI_LENGTH_ERR = "HTTP element REQUEST_URI is longer than the " + MAX_REQUEST_URI_LENGTH + " allowed length.";
31
31
  public final static int MAX_FRAGMENT_LENGTH = 1024;
32
- public final static String MAX_FRAGMENT_LENGTH_ERR = "HTTP element REQUEST_PATH is longer than the 1024 allowed length.";
32
+ public final static String MAX_FRAGMENT_LENGTH_ERR = "HTTP element FRAGMENT is longer than the 1024 allowed length.";
33
33
  public final static int MAX_REQUEST_PATH_LENGTH = getConstLength("PUMA_REQUEST_PATH_MAX_LENGTH", 8192);
34
34
  public final static String MAX_REQUEST_PATH_LENGTH_ERR = "HTTP element REQUEST_PATH is longer than the " + MAX_REQUEST_PATH_LENGTH + " allowed length.";
35
35
  public final static int MAX_QUERY_STRING_LENGTH = getConstLength("PUMA_QUERY_STRING_MAX_LENGTH", 10 * 1024);
data/lib/puma/binder.rb CHANGED
@@ -5,7 +5,6 @@ require 'socket'
5
5
 
6
6
  require_relative 'const'
7
7
  require_relative 'util'
8
- require_relative 'configuration'
9
8
 
10
9
  module Puma
11
10
 
@@ -19,9 +18,9 @@ module Puma
19
18
 
20
19
  RACK_VERSION = [1,6].freeze
21
20
 
22
- def initialize(log_writer, conf = Configuration.new, env: ENV)
21
+ def initialize(log_writer, options, env: ENV)
23
22
  @log_writer = log_writer
24
- @conf = conf
23
+ @options = options
25
24
  @listeners = []
26
25
  @inherited_fds = {}
27
26
  @activated_sockets = {}
@@ -31,10 +30,10 @@ module Puma
31
30
  @proto_env = {
32
31
  "rack.version".freeze => RACK_VERSION,
33
32
  "rack.errors".freeze => log_writer.stderr,
34
- "rack.multithread".freeze => conf.options[:max_threads] > 1,
35
- "rack.multiprocess".freeze => conf.options[:workers] >= 1,
33
+ "rack.multithread".freeze => options[:max_threads] > 1,
34
+ "rack.multiprocess".freeze => options[:workers] >= 1,
36
35
  "rack.run_once".freeze => false,
37
- RACK_URL_SCHEME => conf.options[:rack_url_scheme],
36
+ RACK_URL_SCHEME => options[:rack_url_scheme],
38
37
  "SCRIPT_NAME".freeze => env['SCRIPT_NAME'] || "",
39
38
 
40
39
  # I'd like to set a default CONTENT_TYPE here but some things
@@ -44,7 +43,10 @@ module Puma
44
43
 
45
44
  "QUERY_STRING".freeze => "",
46
45
  SERVER_SOFTWARE => PUMA_SERVER_STRING,
47
- GATEWAY_INTERFACE => CGI_VER
46
+ GATEWAY_INTERFACE => CGI_VER,
47
+
48
+ RACK_AFTER_REPLY => nil,
49
+ RACK_RESPONSE_FINISHED => nil,
48
50
  }
49
51
 
50
52
  @envs = {}
@@ -243,7 +245,7 @@ module Puma
243
245
  cert_key.each do |v|
244
246
  if params[v]&.start_with?('store:')
245
247
  index = Integer(params.delete(v).split('store:').last)
246
- params["#{v}_pem"] = @conf.options[:store][index]
248
+ params["#{v}_pem"] = @options[:store][index]
247
249
  end
248
250
  end
249
251
  MiniSSL::ContextBuilder.new(params, @log_writer).context
data/lib/puma/cli.rb CHANGED
@@ -39,10 +39,8 @@ module Puma
39
39
  @control_url = nil
40
40
  @control_options = {}
41
41
 
42
- setup_options env
43
-
44
42
  begin
45
- @parser.parse! @argv
43
+ setup_options env
46
44
 
47
45
  if file = @argv.shift
48
46
  @conf.configure do |user_config, file_config|
@@ -93,7 +91,7 @@ module Puma
93
91
  #
94
92
 
95
93
  def setup_options(env = ENV)
96
- @conf = Configuration.new({}, {events: @events}, env) do |user_config, file_config|
94
+ @conf = Configuration.new({}, { events: @events }, env) do |user_config, file_config|
97
95
  @parser = OptionParser.new do |o|
98
96
  o.on "-b", "--bind URI", "URI to bind to (tcp://, unix://, ssl://)" do |arg|
99
97
  user_config.bind arg
@@ -240,7 +238,7 @@ module Puma
240
238
  $stdout.puts o
241
239
  exit 0
242
240
  end
243
- end
241
+ end.parse! @argv
244
242
  end
245
243
  end
246
244
  end