puma 6.6.1-java → 7.0.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +89 -4
- data/README.md +11 -24
- data/docs/fork_worker.md +5 -5
- data/docs/kubernetes.md +6 -4
- data/docs/restart.md +2 -2
- data/docs/signals.md +9 -9
- data/docs/stats.md +2 -1
- data/ext/puma_http11/extconf.rb +2 -17
- data/ext/puma_http11/mini_ssl.c +0 -5
- data/lib/puma/binder.rb +10 -8
- data/lib/puma/cli.rb +3 -5
- data/lib/puma/client.rb +31 -31
- data/lib/puma/cluster/worker.rb +9 -10
- data/lib/puma/cluster/worker_handle.rb +34 -5
- data/lib/puma/cluster.rb +12 -13
- data/lib/puma/commonlogger.rb +3 -3
- data/lib/puma/configuration.rb +86 -43
- data/lib/puma/const.rb +9 -10
- data/lib/puma/control_cli.rb +3 -2
- data/lib/puma/detect.rb +2 -0
- data/lib/puma/dsl.rb +108 -81
- data/lib/puma/error_logger.rb +3 -1
- data/lib/puma/events.rb +13 -13
- data/lib/puma/io_buffer.rb +8 -4
- data/lib/puma/launcher/bundle_pruner.rb +1 -1
- data/lib/puma/launcher.rb +28 -29
- data/lib/puma/minissl.rb +0 -1
- data/lib/puma/plugin/systemd.rb +3 -3
- data/lib/puma/rack/urlmap.rb +1 -1
- data/lib/puma/reactor.rb +19 -4
- data/lib/puma/request.rb +26 -23
- data/lib/puma/runner.rb +8 -17
- data/lib/puma/server.rb +80 -48
- data/lib/puma/single.rb +4 -1
- data/lib/puma/thread_pool.rb +27 -81
- data/lib/puma/util.rb +0 -7
- data/lib/puma.rb +10 -0
- data/lib/rack/handler/puma.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1949baa42905d743c05f0bbd075f5537913b6a588e0517269c4a1fca7f3383f5
|
4
|
+
data.tar.gz: '077971ab1d3b3238122a17d862768e7e26d0761e8db4bbf8f2e4288d592059ae'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fea46720ba56f03f0043190d3d2fb827aaa514b34ee79dc86f14ebf8aa7caf0bde5d88d115d6cebe80411728f281fe95f748b47bd0901b1c731163d68c377db3
|
7
|
+
data.tar.gz: 15bb0485ac40aa19cc80f69c0d34108eaca3d75a7ecb6eb4f11bcd6ca0c531d9ad9160e73cce9086ef464d89a7caaa09e9da0946099ea96a81eadfc1fd7db0c3
|
data/History.md
CHANGED
@@ -1,3 +1,58 @@
|
|
1
|
+
## 7.0.0
|
2
|
+
|
3
|
+
* Breaking changes
|
4
|
+
* Set default `max_keep_alive` to 999 ([#3719])
|
5
|
+
* Increase `persistent_timeout` default to 65 seconds ([#3378])
|
6
|
+
* Raise an ArgumentError if no block given to hooks ([#3377])
|
7
|
+
* Don't set env['HTTP_VERSION'] for Rack > 3.1 ([#3711], [#3576])
|
8
|
+
* Runner.rb - remove `ruby_engine` method, deprecated Nov-2024 ([#3701])
|
9
|
+
* Set conditional config defaults after CLI options are parsed and config files are loaded ([#3297])
|
10
|
+
* Response headers set to lowercase ([#3704])
|
11
|
+
* Update minimum Ruby version to 3.0 ([#3698])
|
12
|
+
* Rename callback hooks ([#3438])
|
13
|
+
|
14
|
+
| Old hook name| New hook name|
|
15
|
+
|----------|----------|
|
16
|
+
| on_worker_boot | before_worker_boot |
|
17
|
+
| on_worker_shutdown | before_worker_shutdown |
|
18
|
+
| on_restart | before_restart |
|
19
|
+
| on_booted | after_booted |
|
20
|
+
| on_stopped | after_stopped |
|
21
|
+
| on_refork | before_refork |
|
22
|
+
| on_thread_start | before_thread_start |
|
23
|
+
| on_thread_exit | before_thread_exit |
|
24
|
+
| on_worker_fork | before_worker_fork |
|
25
|
+
|
26
|
+
* Features
|
27
|
+
* Fix long tail response problem with keepalive connections ([#3678]) (Previously released in 7.0.0.pre1, this was a high effort change)
|
28
|
+
* Introduce support for fiber-per-request. ([#3101])
|
29
|
+
* Add support for `rack.response_finished` ([#3681])
|
30
|
+
* Feature/support custom logger with request logs ([#3140])
|
31
|
+
|
32
|
+
* Bugfixes
|
33
|
+
* Fixes a bug where triggering hooks in the ThreadPool fails ([#3716])
|
34
|
+
* Fix error_logger inproperly logging `env[QUERY_STRING]` ([#3713], [#3625])
|
35
|
+
* Fix handling of invalid Transfer-Encoding header errors ([#3702])
|
36
|
+
* Fix socket leak on monitor wakeup `NoMethodError` in `Reactor#select_loop` ([#3696], [#3695])
|
37
|
+
* CI: puma_socket.rb fixup socket/request writes ([#3684])
|
38
|
+
* Warn when RUBY_MN_THREADS env var is set ([#3721])
|
39
|
+
* Improve the DSL `preload_app!` doc ([#3712])
|
40
|
+
* Fix the ability to focus individual tests ([#3705])
|
41
|
+
* Set env['rack.hijack'] to client.method(:full_hijack) ([#3073])
|
42
|
+
|
43
|
+
* Performance
|
44
|
+
* server.rb - initialize ivars `@reactor` and `@env_set_http_version` ([#3714])
|
45
|
+
|
46
|
+
* Refactor
|
47
|
+
* Simplify `Puma::DSL#process_hook` logic ([#3710])
|
48
|
+
* Dry up deprecation warnings and fix deprecation warnings when running CI. ([#3709], [#3708])
|
49
|
+
* Ensure and enforce that configs are loaded before options are accessed ([#3616])
|
50
|
+
|
51
|
+
## 7.0.0.pre1 / 2025-07-31
|
52
|
+
|
53
|
+
* Changed
|
54
|
+
* Fix long tail response problem with keepalive connections ([#3678])
|
55
|
+
|
1
56
|
## 6.6.1 / 2025-07-30
|
2
57
|
|
3
58
|
* Bugfixes
|
@@ -2160,12 +2215,42 @@ be added back in a future date when a java Puma::MiniSSL is added.
|
|
2160
2215
|
* Bugfixes
|
2161
2216
|
* Your bugfix goes here <Most recent on the top, like GitHub> (#Github Number)
|
2162
2217
|
|
2163
|
-
[#
|
2218
|
+
[#3719]:https://github.com/puma/puma/pull/3719 "PR by @schneems, merged 2025-09-03"
|
2219
|
+
[#3378]:https://github.com/puma/puma/pull/3378 "PR by @shayonj, merged 2025-08-19"
|
2220
|
+
[#3377]:https://github.com/puma/puma/pull/3377 "PR by @joshuay03, merged 2025-08-12"
|
2221
|
+
[#3711]:https://github.com/puma/puma/pull/3711 "PR by @MSP-Greg, merged 2025-08-28"
|
2222
|
+
[#3576]:https://github.com/puma/puma/issues/3576 "Issue by @pdalberti, closed 2025-08-28"
|
2223
|
+
[#3701]:https://github.com/puma/puma/pull/3701 "PR by @MSP-Greg, merged 2025-08-26"
|
2224
|
+
[#3297]:https://github.com/puma/puma/pull/3297 "PR by @joshuay03, merged 2025-08-26"
|
2225
|
+
[#3704]:https://github.com/puma/puma/pull/3704 "PR by @schneems, merged 2025-08-25"
|
2226
|
+
[#3698]:https://github.com/puma/puma/pull/3698 "PR by @schneems, merged 2025-08-21"
|
2227
|
+
[#3438]:https://github.com/puma/puma/pull/3438 "PR by @tannakartikey, merged 2025-08-25"
|
2228
|
+
[#3678]:https://github.com/puma/puma/pull/3678 "PR by @MSP-Greg, merged 2025-07-31"
|
2229
|
+
[#3101]:https://github.com/puma/puma/pull/3101 "PR by @ioquatix, merged 2025-08-25"
|
2230
|
+
[#3681]:https://github.com/puma/puma/pull/3681 "PR by @byroot, merged 2025-08-15"
|
2231
|
+
[#3140]:https://github.com/puma/puma/pull/3140 "PR by @phyzical, merged 2025-08-12"
|
2232
|
+
[#3716]:https://github.com/puma/puma/pull/3716 "PR by @yuki24, merged 2025-08-31"
|
2233
|
+
[#3713]:https://github.com/puma/puma/pull/3713 "PR by @MSP-Greg, merged 2025-08-29"
|
2234
|
+
[#3625]:https://github.com/puma/puma/pull/3625 "PR by @bhooshiek-narendiran, closed 2025-08-29"
|
2235
|
+
[#3702]:https://github.com/puma/puma/pull/3702 "PR by @marshall-lee, merged 2025-08-25"
|
2236
|
+
[#3696]:https://github.com/puma/puma/pull/3696 "PR by @joshuay03, merged 2025-08-22"
|
2237
|
+
[#3695]:https://github.com/puma/puma/issues/3695 "Issue by @joshuay03, closed 2025-08-22"
|
2238
|
+
[#3684]:https://github.com/puma/puma/pull/3684 "PR by @MSP-Greg, merged 2025-08-02"
|
2239
|
+
[#3721]:https://github.com/puma/puma/pull/3721 "PR by @schneems, merged 2025-09-03"
|
2240
|
+
[#3712]:https://github.com/puma/puma/pull/3712 "PR by @joshuay03, merged 2025-08-28"
|
2241
|
+
[#3705]:https://github.com/puma/puma/pull/3705 "PR by @schneems, merged 2025-08-25"
|
2242
|
+
[#3073]:https://github.com/puma/puma/pull/3073 "PR by @MSP-Greg, merged 2025-08-12"
|
2243
|
+
[#3714]:https://github.com/puma/puma/pull/3714 "PR by @MSP-Greg, merged 2025-08-29"
|
2244
|
+
[#3710]:https://github.com/puma/puma/pull/3710 "PR by @joshuay03, merged 2025-08-28"
|
2245
|
+
[#3709]:https://github.com/puma/puma/pull/3709 "PR by @MSP-Greg, merged 2025-08-28"
|
2246
|
+
[#3708]:https://github.com/puma/puma/issues/3708 "Issue by @schneems, closed 2025-08-28"
|
2247
|
+
[#3616]:https://github.com/puma/puma/pull/3616 "PR by @joshuay03, merged 2025-08-25"
|
2248
|
+
[#3635]:https://github.com/puma/puma/pull/3635 "PR by @LevitatingBusinessMan, merged 2025-05-08"
|
2164
2249
|
[#3572]:https://github.com/puma/puma/pull/3572 "PR by @barthez, merged 2025-02-06"
|
2250
|
+
[#3601]:https://github.com/puma/puma/pull/3601 "PR by @joshuay03, merged 2025-01-31"
|
2165
2251
|
[#3586]:https://github.com/puma/puma/pull/3586 "PR by @MSP-Greg, merged 2025-02-03"
|
2166
2252
|
[#3598]:https://github.com/puma/puma/pull/3598 "PR by @joshuay03, merged 2025-01-31"
|
2167
|
-
[#
|
2168
|
-
[#3635]:https://github.com/puma/puma/pull/3635 "PR by @LevitatingBusinessMan, merged 2025-05-08"
|
2253
|
+
[#3680]:https://github.com/puma/puma/pull/3680 "PR by @byroot, merged 2025-07-31"
|
2169
2254
|
[#3570]:https://github.com/puma/puma/pull/3570 "PR by @mohamedhafez, merged 2024-12-30"
|
2170
2255
|
[#3567]:https://github.com/puma/puma/issues/3567 "Issue by @mohamedhafez, closed 2024-12-30"
|
2171
2256
|
[#3383]:https://github.com/puma/puma/pull/3383 "PR by @joshuay03, merged 2024-11-29"
|
@@ -2764,7 +2849,7 @@ be added back in a future date when a java Puma::MiniSSL is added.
|
|
2764
2849
|
[#1022]:https://github.com/puma/puma/issues/1022 "Issue by @AKovtunov, closed 2017-08-16"
|
2765
2850
|
[#958]:https://github.com/puma/puma/issues/958 "Issue by @lalitlogical, closed 2016-04-23"
|
2766
2851
|
[#782]:https://github.com/puma/puma/issues/782 "Issue by @Tonkpils, closed 2016-07-19"
|
2767
|
-
[#1010]:https://github.com/puma/puma/issues/1010 "Issue by @
|
2852
|
+
[#1010]:https://github.com/puma/puma/issues/1010 "Issue by @mirineumark, closed 2016-07-19"
|
2768
2853
|
[#959]:https://github.com/puma/puma/issues/959 "Issue by @mwpastore, closed 2016-04-22"
|
2769
2854
|
[#840]:https://github.com/puma/puma/issues/840 "Issue by @marisawallace, closed 2016-04-07"
|
2770
2855
|
[#1007]:https://github.com/puma/puma/pull/1007 "PR by @willnet, merged 2016-06-24"
|
data/README.md
CHANGED
@@ -124,7 +124,7 @@ For an in-depth discussion of the tradeoffs of thread and process count settings
|
|
124
124
|
|
125
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
|
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
|
@@ -142,7 +142,7 @@ Preloading can’t be used with phased restart, since phased restart kills and r
|
|
142
142
|
|
143
143
|
#### Cluster mode hooks
|
144
144
|
|
145
|
-
When using
|
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
|
-
|
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 `
|
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
|
-
|
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
|
@@ -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 `
|
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 `
|
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 `
|
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
|
-
|
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
|
-
|
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
|
-
|
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 `
|
28
|
-
- When initially forking the parent process to the worker 0 child, `before_fork` will trigger on the parent process and `
|
29
|
-
- When forking the worker 0 child to grandchild workers, `
|
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 `
|
33
|
-
- Consider to copy logic from your `
|
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:
|
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
|
-
* `
|
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
|
-
* `
|
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
@@ -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
|
-
|
57
|
+
before_worker_fork
|
58
58
|
after_worker_fork
|
59
59
|
|
60
60
|
Gemfile in context
|
61
61
|
|
62
|
-
|
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
|
-
|
71
|
-
|
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
|
-
|
76
|
+
before_worker_fork
|
77
77
|
after_worker_fork
|
78
78
|
|
79
79
|
Gemfile in context
|
80
80
|
|
81
|
-
|
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
|
-
|
90
|
-
|
89
|
+
before_worker_shutdown
|
90
|
+
before_worker_fork
|
91
91
|
after_worker_fork
|
92
92
|
|
93
93
|
Gemfile in context
|
94
94
|
|
95
|
-
|
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/ext/puma_http11/extconf.rb
CHANGED
@@ -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
|
-
|
70
|
-
|
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")
|
data/ext/puma_http11/mini_ssl.c
CHANGED
@@ -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
|
|
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,
|
21
|
+
def initialize(log_writer, options, env: ENV)
|
23
22
|
@log_writer = log_writer
|
24
|
-
@
|
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 =>
|
35
|
-
"rack.multiprocess".freeze =>
|
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 =>
|
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"] = @
|
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
|
-
|
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
|
data/lib/puma/client.rb
CHANGED
@@ -1,13 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class IO
|
4
|
-
# We need to use this for a jruby work around on both 1.8 and 1.9.
|
5
|
-
# So this either creates the constant (on 1.8), or harmlessly
|
6
|
-
# reopens it (on 1.9).
|
7
|
-
module WaitReadable
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
3
|
require_relative 'detect'
|
12
4
|
require_relative 'io_buffer'
|
13
5
|
require 'tempfile'
|
@@ -64,6 +56,11 @@ module Puma
|
|
64
56
|
|
65
57
|
TE_ERR_MSG = 'Invalid Transfer-Encoding'
|
66
58
|
|
59
|
+
# See:
|
60
|
+
# https://httpwg.org/specs/rfc9110.html#rfc.section.5.6.1.1
|
61
|
+
# https://httpwg.org/specs/rfc9112.html#rfc.section.6.1
|
62
|
+
STRIP_OWS = /\A[ \t]+|[ \t]+\z/
|
63
|
+
|
67
64
|
# The object used for a request with no body. All requests with
|
68
65
|
# no body share this one object since it has no state.
|
69
66
|
EmptyBody = NullIO.new
|
@@ -111,7 +108,8 @@ module Puma
|
|
111
108
|
end
|
112
109
|
|
113
110
|
attr_reader :env, :to_io, :body, :io, :timeout_at, :ready, :hijacked,
|
114
|
-
:tempfile, :io_buffer, :http_content_length_limit_exceeded
|
111
|
+
:tempfile, :io_buffer, :http_content_length_limit_exceeded,
|
112
|
+
:requests_served
|
115
113
|
|
116
114
|
attr_writer :peerip, :http_content_length_limit
|
117
115
|
|
@@ -133,9 +131,9 @@ module Puma
|
|
133
131
|
"#<Puma::Client:0x#{object_id.to_s(16)} @ready=#{@ready.inspect}>"
|
134
132
|
end
|
135
133
|
|
136
|
-
# For the hijack protocol
|
137
|
-
#
|
138
|
-
def
|
134
|
+
# For the full hijack protocol, `env['rack.hijack']` is set to
|
135
|
+
# `client.method :full_hijack`
|
136
|
+
def full_hijack
|
139
137
|
@hijacked = true
|
140
138
|
env[HIJACK_IO] ||= @io
|
141
139
|
end
|
@@ -150,11 +148,12 @@ module Puma
|
|
150
148
|
end
|
151
149
|
|
152
150
|
# Number of seconds until the timeout elapses.
|
151
|
+
# @!attribute [r] timeout
|
153
152
|
def timeout
|
154
153
|
[@timeout_at - Process.clock_gettime(Process::CLOCK_MONOTONIC), 0].max
|
155
154
|
end
|
156
155
|
|
157
|
-
def reset
|
156
|
+
def reset
|
158
157
|
@parser.reset
|
159
158
|
@io_buffer.reset
|
160
159
|
@read_header = true
|
@@ -166,7 +165,10 @@ module Puma
|
|
166
165
|
@peerip = nil if @remote_addr_header
|
167
166
|
@in_last_chunk = false
|
168
167
|
@http_content_length_limit_exceeded = false
|
168
|
+
end
|
169
169
|
|
170
|
+
# only used with back-to-back requests contained in the buffer
|
171
|
+
def process_back_to_back_requests
|
170
172
|
if @buffer
|
171
173
|
return false unless try_to_parse_proxy_protocol
|
172
174
|
|
@@ -178,25 +180,20 @@ module Puma
|
|
178
180
|
raise HttpParserError,
|
179
181
|
"HEADER is longer than allowed, aborting client early."
|
180
182
|
end
|
181
|
-
|
182
|
-
return false
|
183
|
-
else
|
184
|
-
begin
|
185
|
-
if fast_check && @to_io.wait_readable(FAST_TRACK_KA_TIMEOUT)
|
186
|
-
return try_to_finish
|
187
|
-
end
|
188
|
-
rescue IOError
|
189
|
-
# swallow it
|
190
|
-
end
|
191
183
|
end
|
192
184
|
end
|
193
185
|
|
186
|
+
# if a client sends back-to-back requests, the buffer may contain one or more
|
187
|
+
# of them.
|
188
|
+
def has_back_to_back_requests?
|
189
|
+
!(@buffer.nil? || @buffer.empty?)
|
190
|
+
end
|
191
|
+
|
194
192
|
def close
|
195
193
|
tempfile_close
|
196
194
|
begin
|
197
195
|
@io.close
|
198
196
|
rescue IOError, Errno::EBADF
|
199
|
-
Puma::Util.purge_interrupt_queue
|
200
197
|
end
|
201
198
|
end
|
202
199
|
|
@@ -291,8 +288,10 @@ module Puma
|
|
291
288
|
|
292
289
|
def eagerly_finish
|
293
290
|
return true if @ready
|
294
|
-
|
295
|
-
|
291
|
+
while @to_io.wait_readable(0) # rubocop: disable Style/WhileUntilModifier
|
292
|
+
return true if try_to_finish
|
293
|
+
end
|
294
|
+
false
|
296
295
|
end
|
297
296
|
|
298
297
|
def finish(timeout)
|
@@ -412,17 +411,18 @@ module Puma
|
|
412
411
|
if te
|
413
412
|
te_lwr = te.downcase
|
414
413
|
if te.include? ','
|
415
|
-
te_ary = te_lwr.split
|
414
|
+
te_ary = te_lwr.split(',').each { |te| te.gsub!(STRIP_OWS, "") }
|
416
415
|
te_count = te_ary.count CHUNKED
|
417
416
|
te_valid = te_ary[0..-2].all? { |e| ALLOWED_TRANSFER_ENCODING.include? e }
|
418
|
-
if
|
419
|
-
@env.delete TRANSFER_ENCODING2
|
420
|
-
return setup_chunked_body body
|
421
|
-
elsif te_count >= 1
|
417
|
+
if te_count > 1
|
422
418
|
raise HttpParserError , "#{TE_ERR_MSG}, multiple chunked: '#{te}'"
|
419
|
+
elsif te_ary.last != CHUNKED
|
420
|
+
raise HttpParserError , "#{TE_ERR_MSG}, last value must be chunked: '#{te}'"
|
423
421
|
elsif !te_valid
|
424
422
|
raise HttpParserError501, "#{TE_ERR_MSG}, unknown value: '#{te}'"
|
425
423
|
end
|
424
|
+
@env.delete TRANSFER_ENCODING2
|
425
|
+
return setup_chunked_body body
|
426
426
|
elsif te_lwr == CHUNKED
|
427
427
|
@env.delete TRANSFER_ENCODING2
|
428
428
|
return setup_chunked_body body
|