puma 7.0.0.pre1-java → 7.0.1-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 +87 -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/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 +14 -17
- data/lib/puma/cluster/worker.rb +0 -2
- data/lib/puma/cluster/worker_handle.rb +2 -3
- data/lib/puma/cluster.rb +7 -11
- data/lib/puma/commonlogger.rb +3 -3
- data/lib/puma/configuration.rb +83 -38
- data/lib/puma/const.rb +8 -7
- data/lib/puma/control_cli.rb +3 -2
- data/lib/puma/detect.rb +2 -0
- data/lib/puma/dsl.rb +96 -77
- data/lib/puma/error_logger.rb +3 -1
- data/lib/puma/events.rb +25 -10
- 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/puma_http11.jar +0 -0
- data/lib/puma/rack/urlmap.rb +1 -1
- data/lib/puma/reactor.rb +8 -4
- data/lib/puma/request.rb +22 -10
- data/lib/puma/runner.rb +8 -17
- data/lib/puma/server.rb +23 -13
- data/lib/puma/single.rb +4 -1
- data/lib/puma/thread_pool.rb +3 -14
- data/lib/puma/util.rb +0 -7
- data/lib/puma.rb +10 -0
- data/lib/rack/handler/puma.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69d4fe6e08bfc4ea81063374e299c391062feb83cd1f05a93a244795af435534
|
4
|
+
data.tar.gz: cb8d177378160d56a9bda5d18eec33be2f6bb2e3cf565ff1ca2b3ca60ce2e034
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beadf2630b6dbe6642261bb6e97118c0884264e4a2a89a07d3f77f0ef6e4b6f002640a4dd45bcb3be980b0b7c33af962299052036894c3cb108fc6ededc978a7
|
7
|
+
data.tar.gz: 42159af3361b75a011774631c637eb80d36484dda0613de6e10c6e0fdfdd0479158208fc049907e3c6eef6c12f0cca53ff86ec0688e6c5e51b5ef070bf0c1215
|
data/History.md
CHANGED
@@ -1,3 +1,57 @@
|
|
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
|
+
|
1
55
|
## 7.0.0.pre1 / 2025-07-31
|
2
56
|
|
3
57
|
* Changed
|
@@ -2165,13 +2219,42 @@ be added back in a future date when a java Puma::MiniSSL is added.
|
|
2165
2219
|
* Bugfixes
|
2166
2220
|
* Your bugfix goes here <Most recent on the top, like GitHub> (#Github Number)
|
2167
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"
|
2168
2233
|
[#3678]:https://github.com/puma/puma/pull/3678 "PR by @MSP-Greg, merged 2025-07-31"
|
2169
|
-
[#
|
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"
|
2170
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"
|
2171
2255
|
[#3586]:https://github.com/puma/puma/pull/3586 "PR by @MSP-Greg, merged 2025-02-03"
|
2172
2256
|
[#3598]:https://github.com/puma/puma/pull/3598 "PR by @joshuay03, merged 2025-01-31"
|
2173
|
-
[#
|
2174
|
-
[#3635]:https://github.com/puma/puma/pull/3635 "PR by @LevitatingBusinessMan, merged 2025-05-08"
|
2257
|
+
[#3680]:https://github.com/puma/puma/pull/3680 "PR by @byroot, merged 2025-07-31"
|
2175
2258
|
[#3570]:https://github.com/puma/puma/pull/3570 "PR by @mohamedhafez, merged 2024-12-30"
|
2176
2259
|
[#3567]:https://github.com/puma/puma/issues/3567 "Issue by @mohamedhafez, closed 2024-12-30"
|
2177
2260
|
[#3383]:https://github.com/puma/puma/pull/3383 "PR by @joshuay03, merged 2024-11-29"
|
@@ -2770,7 +2853,7 @@ be added back in a future date when a java Puma::MiniSSL is added.
|
|
2770
2853
|
[#1022]:https://github.com/puma/puma/issues/1022 "Issue by @AKovtunov, closed 2017-08-16"
|
2771
2854
|
[#958]:https://github.com/puma/puma/issues/958 "Issue by @lalitlogical, closed 2016-04-23"
|
2772
2855
|
[#782]:https://github.com/puma/puma/issues/782 "Issue by @Tonkpils, closed 2016-07-19"
|
2773
|
-
[#1010]:https://github.com/puma/puma/issues/1010 "Issue by @
|
2856
|
+
[#1010]:https://github.com/puma/puma/issues/1010 "Issue by @mirineumark, closed 2016-07-19"
|
2774
2857
|
[#959]:https://github.com/puma/puma/issues/959 "Issue by @mwpastore, closed 2016-04-22"
|
2775
2858
|
[#840]:https://github.com/puma/puma/issues/840 "Issue by @marisawallace, closed 2016-04-07"
|
2776
2859
|
[#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/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
|
@@ -134,9 +131,9 @@ module Puma
|
|
134
131
|
"#<Puma::Client:0x#{object_id.to_s(16)} @ready=#{@ready.inspect}>"
|
135
132
|
end
|
136
133
|
|
137
|
-
# For the hijack protocol
|
138
|
-
#
|
139
|
-
def
|
134
|
+
# For the full hijack protocol, `env['rack.hijack']` is set to
|
135
|
+
# `client.method :full_hijack`
|
136
|
+
def full_hijack
|
140
137
|
@hijacked = true
|
141
138
|
env[HIJACK_IO] ||= @io
|
142
139
|
end
|
@@ -197,7 +194,6 @@ module Puma
|
|
197
194
|
begin
|
198
195
|
@io.close
|
199
196
|
rescue IOError, Errno::EBADF
|
200
|
-
Puma::Util.purge_interrupt_queue
|
201
197
|
end
|
202
198
|
end
|
203
199
|
|
@@ -415,17 +411,18 @@ module Puma
|
|
415
411
|
if te
|
416
412
|
te_lwr = te.downcase
|
417
413
|
if te.include? ','
|
418
|
-
te_ary = te_lwr.split
|
414
|
+
te_ary = te_lwr.split(',').each { |te| te.gsub!(STRIP_OWS, "") }
|
419
415
|
te_count = te_ary.count CHUNKED
|
420
416
|
te_valid = te_ary[0..-2].all? { |e| ALLOWED_TRANSFER_ENCODING.include? e }
|
421
|
-
if
|
422
|
-
@env.delete TRANSFER_ENCODING2
|
423
|
-
return setup_chunked_body body
|
424
|
-
elsif te_count >= 1
|
417
|
+
if te_count > 1
|
425
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}'"
|
426
421
|
elsif !te_valid
|
427
422
|
raise HttpParserError501, "#{TE_ERR_MSG}, unknown value: '#{te}'"
|
428
423
|
end
|
424
|
+
@env.delete TRANSFER_ENCODING2
|
425
|
+
return setup_chunked_body body
|
429
426
|
elsif te_lwr == CHUNKED
|
430
427
|
@env.delete TRANSFER_ENCODING2
|
431
428
|
return setup_chunked_body body
|
data/lib/puma/cluster/worker.rb
CHANGED
@@ -110,7 +110,6 @@ module Puma
|
|
110
110
|
begin
|
111
111
|
@worker_write << "#{PIPE_BOOT}#{Process.pid}:#{index}\n"
|
112
112
|
rescue SystemCallError, IOError
|
113
|
-
Puma::Util.purge_interrupt_queue
|
114
113
|
STDERR.puts "Master seems to have exited, exiting."
|
115
114
|
return
|
116
115
|
end
|
@@ -138,7 +137,6 @@ module Puma
|
|
138
137
|
io << payload.sub(/,\z/, " }\n")
|
139
138
|
server.reset_max
|
140
139
|
rescue IOError
|
141
|
-
Puma::Util.purge_interrupt_queue
|
142
140
|
break
|
143
141
|
end
|
144
142
|
sleep @options[:worker_check_interval]
|
@@ -57,10 +57,9 @@ module Puma
|
|
57
57
|
def ping!(status)
|
58
58
|
hsh = {}
|
59
59
|
k, v = nil, nil
|
60
|
-
|
61
|
-
status.tr('}{"', '').strip.split(", ").each do |kv|
|
60
|
+
status.tr('}{"', '').strip.split(", ") do |kv|
|
62
61
|
cntr = 0
|
63
|
-
kv.split(':')
|
62
|
+
kv.split(':') do |t|
|
64
63
|
if cntr == 0
|
65
64
|
k = t
|
66
65
|
cntr = 1
|
data/lib/puma/cluster.rb
CHANGED
@@ -46,8 +46,7 @@ module Puma
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def start_phased_restart(refork = false)
|
49
|
-
@events.
|
50
|
-
|
49
|
+
@events.fire_before_restart!
|
51
50
|
@phase += 1
|
52
51
|
if refork
|
53
52
|
log "- Starting worker refork, phase: #{@phase}"
|
@@ -355,7 +354,7 @@ module Puma
|
|
355
354
|
|
356
355
|
stop_workers
|
357
356
|
stop
|
358
|
-
@events.
|
357
|
+
@events.fire_after_stopped!
|
359
358
|
raise(SignalException, "SIGTERM") if @options[:raise_exception_on_sigterm]
|
360
359
|
exit 0 # Clean exit, workers were stopped
|
361
360
|
end
|
@@ -372,12 +371,8 @@ module Puma
|
|
372
371
|
|
373
372
|
if preload?
|
374
373
|
# Threads explicitly marked as fork safe will be ignored. Used in Rails,
|
375
|
-
# but may be used by anyone.
|
376
|
-
|
377
|
-
# where calling thread_variable_get on a Process::Waiter will segfault.
|
378
|
-
# We can drop that clause once those versions of Ruby are no longer
|
379
|
-
# supported.
|
380
|
-
fork_safe = ->(t) { !t.is_a?(Process::Waiter) && t.thread_variable_get(:fork_safe) }
|
374
|
+
# but may be used by anyone.
|
375
|
+
fork_safe = ->(t) { t.thread_variable_get(:fork_safe) }
|
381
376
|
|
382
377
|
before = Thread.list.reject(&fork_safe)
|
383
378
|
|
@@ -426,6 +421,7 @@ module Puma
|
|
426
421
|
|
427
422
|
log "Use Ctrl-C to stop"
|
428
423
|
|
424
|
+
warn_ruby_mn_threads
|
429
425
|
single_worker_warning
|
430
426
|
|
431
427
|
redirect_io
|
@@ -514,7 +510,7 @@ module Puma
|
|
514
510
|
end
|
515
511
|
|
516
512
|
if !booted && @workers.none? {|worker| worker.last_status.empty?}
|
517
|
-
@events.
|
513
|
+
@events.fire_after_booted!
|
518
514
|
debug_loaded_extensions("Loaded Extensions - master:") if @log_writer.debug?
|
519
515
|
booted = true
|
520
516
|
end
|
@@ -531,7 +527,7 @@ module Puma
|
|
531
527
|
end
|
532
528
|
|
533
529
|
if in_phased_restart && workers_not_booted.zero?
|
534
|
-
@events.
|
530
|
+
@events.fire_after_booted!
|
535
531
|
debug_loaded_extensions("Loaded Extensions - master:") if @log_writer.debug?
|
536
532
|
in_phased_restart = false
|
537
533
|
end
|