puma 8.0.2 → 8.1.2
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 +154 -0
- data/README.md +28 -378
- data/docs/binding.md +135 -0
- data/docs/cluster_mode.md +241 -0
- data/docs/configuration.md +78 -0
- data/docs/{stats.md → control_server.md} +28 -8
- data/docs/{deployment.md → deployment/README.md} +23 -7
- data/docs/{kubernetes.md → deployment/kubernetes.md} +4 -4
- data/docs/{systemd.md → deployment/systemd.md} +4 -2
- data/docs/plugins.md +62 -3
- data/docs/puma_support.md +92 -0
- data/docs/rails_dev_mode.md +2 -2
- data/docs/restart.md +8 -3
- data/docs/signals.md +4 -2
- data/docs/{5.0-Upgrade.md → upgrading/5.0-Upgrade.md} +3 -3
- data/docs/{6.0-Upgrade.md → upgrading/6.0-Upgrade.md} +3 -3
- data/docs/{7.0-Upgrade.md → upgrading/7.0-Upgrade.md} +2 -2
- data/docs/{8.0-Upgrade.md → upgrading/8.0-Upgrade.md} +4 -4
- data/ext/puma_http11/extconf.rb +2 -0
- data/ext/puma_http11/http11_parser.c +6 -2
- data/ext/puma_http11/mini_ssl.c +18 -7
- data/ext/puma_http11/puma_http11.c +28 -3
- data/lib/puma/binder.rb +29 -0
- data/lib/puma/cli.rb +6 -0
- data/lib/puma/client.rb +178 -44
- data/lib/puma/client_env.rb +32 -18
- data/lib/puma/cluster/worker.rb +109 -33
- data/lib/puma/cluster/worker_handle.rb +16 -0
- data/lib/puma/cluster.rb +173 -45
- data/lib/puma/commonlogger.rb +3 -3
- data/lib/puma/configuration.rb +23 -3
- data/lib/puma/const.rb +14 -9
- data/lib/puma/control_cli.rb +14 -3
- data/lib/puma/dsl.rb +279 -92
- data/lib/puma/launcher.rb +6 -4
- data/lib/puma/minissl.rb +98 -56
- data/lib/puma/plugin/systemd.rb +1 -1
- data/lib/puma/reactor.rb +35 -3
- data/lib/puma/response.rb +28 -6
- data/lib/puma/runner.rb +5 -1
- data/lib/puma/sd_notify.rb +4 -1
- data/lib/puma/server.rb +131 -35
- data/lib/puma/thread_pool.rb +12 -1
- data/lib/puma/util.rb +8 -4
- data/lib/puma.rb +1 -1
- metadata +19 -31
- data/docs/fork_worker.md +0 -41
- data/docs/grpc.md +0 -62
- data/docs/jungle/README.md +0 -9
- data/docs/testing_benchmarks_local_files.md +0 -150
- data/docs/testing_test_rackup_ci_files.md +0 -36
- data/ext/puma_http11/PumaHttp11Service.java +0 -17
- data/ext/puma_http11/http11_parser.java.rl +0 -131
- data/ext/puma_http11/http11_parser.rl +0 -149
- data/ext/puma_http11/http11_parser_common.rl +0 -54
- data/ext/puma_http11/no_ssl/PumaHttp11Service.java +0 -15
- data/ext/puma_http11/org/jruby/puma/EnvKey.java +0 -241
- data/ext/puma_http11/org/jruby/puma/Http11.java +0 -321
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +0 -441
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +0 -509
- data/tools/Dockerfile +0 -26
- data/tools/trickletest.rb +0 -44
- /data/docs/{nginx.md → deployment/nginx.md} +0 -0
- /data/docs/{jungle → deployment}/rc.d/README.md +0 -0
- /data/docs/{jungle → deployment}/rc.d/puma +0 -0
- /data/docs/{jungle → deployment}/rc.d/puma.conf +0 -0
data/docs/plugins.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# Plugins
|
|
2
2
|
|
|
3
3
|
Puma 3.0 added support for plugins that can augment configuration and service
|
|
4
4
|
operations.
|
|
@@ -14,7 +14,7 @@ There are two canonical plugins to aid in the development of new plugins:
|
|
|
14
14
|
Plugins are activated in a Puma configuration file (such as `config/puma.rb`)
|
|
15
15
|
by adding `plugin "name"`, such as `plugin "heroku"`.
|
|
16
16
|
|
|
17
|
-
Plugins are activated based on path requirements so
|
|
17
|
+
Plugins are activated based on path requirements, so activating the `heroku`
|
|
18
18
|
plugin is much like `require "puma/plugin/heroku"`. This allows gems to provide
|
|
19
19
|
multiple plugins (as well as unrelated gems to provide Puma plugins).
|
|
20
20
|
|
|
@@ -39,4 +39,63 @@ public API for plugins.
|
|
|
39
39
|
|
|
40
40
|
## Binder hooks
|
|
41
41
|
|
|
42
|
-
There's `Puma::Binder#before_parse` method that allows
|
|
42
|
+
There's a `Puma::Binder#before_parse` method that allows adding a proc to run before the body of `Puma::Binder#parse`. Example of usage can be found in [that repository](https://github.com/anchordotdev/puma-acme/blob/v0.1.3/lib/puma/acme/plugin.rb#L97-L118) (`before_parse_hook` could be renamed `before_parse`, making monkey patching of [binder.rb](https://github.com/anchordotdev/puma-acme/blob/v0.1.3/lib/puma/acme/binder.rb) unnecessary).
|
|
43
|
+
|
|
44
|
+
## Community plugins
|
|
45
|
+
|
|
46
|
+
* [puma-metrics](https://github.com/harmjanblok/puma-metrics) — export Puma metrics to Prometheus
|
|
47
|
+
* [puma-plugin-statsd](https://github.com/yob/puma-plugin-statsd) — send Puma metrics to statsd
|
|
48
|
+
* [puma-plugin-systemd](https://github.com/sj26/puma-plugin-systemd) — deeper integration with systemd for notify, status and watchdog. Puma 5.1.0 integrated notify and watchdog, which probably conflicts with this plugin. Puma 6.1.0 added status support which obsoletes the plugin entirely.
|
|
49
|
+
* [puma-plugin-telemetry](https://github.com/babbel/puma-plugin-telemetry) - telemetry plugin for Puma offering various targets to publish
|
|
50
|
+
* [puma-acme](https://github.com/anchordotdev/puma-acme) - automatic SSL/HTTPS certificate provisioning and setup
|
|
51
|
+
|
|
52
|
+
## Example: stopping Puma via Redis
|
|
53
|
+
|
|
54
|
+
```ruby
|
|
55
|
+
require 'puma/plugin'
|
|
56
|
+
require 'redis'
|
|
57
|
+
|
|
58
|
+
# How to stop Puma on Heroku
|
|
59
|
+
# - You can't use normal methods because the dyno is not accessible
|
|
60
|
+
# - There's no file system, no way to send signals
|
|
61
|
+
# but ...
|
|
62
|
+
# - You can use Redis or Memcache; any network distributed key-value
|
|
63
|
+
# store
|
|
64
|
+
|
|
65
|
+
# 1. Add this plugin to your 'lib' directory
|
|
66
|
+
# 2. In the `puma.rb` config file add the following lines
|
|
67
|
+
# === Plugins ===
|
|
68
|
+
# require './lib/puma/plugin/redis_stop_puma'
|
|
69
|
+
# plugin 'redis_stop_puma'
|
|
70
|
+
# 3. Now, when you set the redis key "puma::restart::web.1", your web.1 dyno
|
|
71
|
+
# will restart
|
|
72
|
+
# 4. Sniffing the Heroku logs for R14 errors is application (and configuration)
|
|
73
|
+
# specific. I use the Logentries service, watch for the pattern and the call
|
|
74
|
+
# a webhook back into my app to set the Redis key. YMMV
|
|
75
|
+
|
|
76
|
+
# You can test this locally by setting the DYNO environment variable when
|
|
77
|
+
# when starting puma, e.g. `DYNO=pants.1 puma`
|
|
78
|
+
|
|
79
|
+
Puma::Plugin.create do
|
|
80
|
+
def start(launcher)
|
|
81
|
+
|
|
82
|
+
hostname = ENV['DYNO']
|
|
83
|
+
return unless hostname
|
|
84
|
+
|
|
85
|
+
redis = Redis.new(url: ENV.fetch('REDIS_URL', nil))
|
|
86
|
+
return unless redis.ping == 'PONG'
|
|
87
|
+
|
|
88
|
+
in_background do
|
|
89
|
+
while true
|
|
90
|
+
sleep 2
|
|
91
|
+
if message = redis.get("puma::restart::#{hostname}")
|
|
92
|
+
redis.del("puma::restart::#{hostname}")
|
|
93
|
+
$stderr.puts message
|
|
94
|
+
launcher.stop
|
|
95
|
+
break
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
```
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Puma Support Policy
|
|
2
|
+
|
|
3
|
+
## What
|
|
4
|
+
|
|
5
|
+
This document's purpose is to help users and contributors of this library make future plans based on the trajectory of this project. It is loosely worded and should be expected to change over time. Maintainers and contributors are encouraged to follow the guidance here but are not strictly bound by it.
|
|
6
|
+
|
|
7
|
+
## What does "supported" mean?
|
|
8
|
+
|
|
9
|
+
Puma is a community-run project. "Support" means "what do the maintainers pay attention to and what are they likely to merge", and doesn't mean that we do anything by any particular date, or even at all. We may all jet off to a private island tomorrow and never speak again.
|
|
10
|
+
|
|
11
|
+
But, if we do decide to keep devoting our free time to open source software, we will **support the Ruby versions, Ruby implementations, Rack versions, and operating systems which run on our CI**, in any combination, even combinations that CI doesn't run directly.
|
|
12
|
+
|
|
13
|
+
If you open a PR or bug report for a combination of those factors outside of our CI matrix, we may still accept it if it's a small and low-risk fix.
|
|
14
|
+
|
|
15
|
+
We may add environments to CI at any time, but we only drop a supported environment in a minor or major release.
|
|
16
|
+
|
|
17
|
+
## CI matrix
|
|
18
|
+
|
|
19
|
+
CI aims for the most coverage with the fewest jobs.
|
|
20
|
+
|
|
21
|
+
Every OS and architecture runs the oldest supported Ruby on its oldest runner image, and the newest Ruby on its newest image.
|
|
22
|
+
|
|
23
|
+
On x64, a few more jobs fill in the gaps:
|
|
24
|
+
|
|
25
|
+
- The newest Ubuntu image that can build every supported Ruby runs all of them.
|
|
26
|
+
- The newest Ubuntu image also runs Ruby head with YJIT, plus JRuby and TruffleRuby and their head versions.
|
|
27
|
+
- The newest Windows image also runs the ucrt and mswin builds.
|
|
28
|
+
- The oldest Ubuntu and Windows images also run the oldest Ruby without SSL.
|
|
29
|
+
- The oldest Ubuntu image also runs the oldest Ruby with the oldest supported Rack.
|
|
30
|
+
|
|
31
|
+
## Puma release support policy
|
|
32
|
+
|
|
33
|
+
By default, Puma supports one release version, the latest release. That means if there is a bug in 3.2.1 (made-up numbers for example only), but the latest release is 4.3.2, the bug must be reproduced in 4.3.2 to qualify for support.
|
|
34
|
+
|
|
35
|
+
When a new major (and sometimes minor) version is released, Puma maintainers will try to preserve the status of the old version via branches and/or tags. Puma maintainers can choose to backport fixes to older versions and cut a release of older versions, but this behavior should not be assumed.
|
|
36
|
+
|
|
37
|
+
If a bug report cannot be reproduced with the latest Puma version, it may be closed.
|
|
38
|
+
|
|
39
|
+
## Ruby version support policy
|
|
40
|
+
|
|
41
|
+
"Ruby version" refers to the https://github.com/ruby/ruby implementation. Puma also supports other Ruby implementations (the origin of Puma involves an alternate Ruby implementation, Rubinius); see below.
|
|
42
|
+
|
|
43
|
+
Ruby upstream support is documented at https://www.ruby-lang.org/en/downloads/branches/. A "minor" version is X.Y, with X.Y.Z being a patch release. Puma supports every Ruby minor version that is not EOL upstream. Puma may also continue to support older, EOL Ruby versions; the gemspec's `required_ruby_version` declares the oldest supported version. Maintainers decide when to raise that minimum. The Puma team recommends you always use the latest Ruby release.
|
|
44
|
+
|
|
45
|
+
When Puma supports a Ruby version, it will include that version in the CI matrix. CI runs only the most recent patch version of each supported Ruby minor version. If a bug is reported, the report must be reproducible using the most recent patch version of a currently supported Ruby minor version.
|
|
46
|
+
|
|
47
|
+
Puma may rely on upstream support to fix bugs in Ruby rather than working around them. That means, if a bug exists only in a Ruby version that is EOL upstream, it may be closed (it's not guaranteed that we will work around legacy Ruby issues).
|
|
48
|
+
|
|
49
|
+
When Puma does work around a bug in a specific Ruby patch version, the workaround stays until Puma drops support for that Ruby minor version.
|
|
50
|
+
|
|
51
|
+
## Alternate implementations of Ruby (version support policy)
|
|
52
|
+
|
|
53
|
+
An example of an "alternate" implementation of Ruby is JRuby. Ruby implementations typically target a specific "spec" of ruby/ruby, for example, JRuby 10.0 targets ruby/ruby version 3.4. The target version of a supported implementation must be within the above "Ruby version support policy." Additionally, the implementation release must be supported upstream.
|
|
54
|
+
|
|
55
|
+
Puma supports the JRuby implementation. Puma supports the TruffleRuby implementation.
|
|
56
|
+
|
|
57
|
+
## Rack (and SPEC) version support
|
|
58
|
+
|
|
59
|
+
From the current Rack documentation https://github.com/rack/rack?tab=readme-ov-file#version-support, Rack lists support levels to be:
|
|
60
|
+
|
|
61
|
+
- Bug fixes and security patches
|
|
62
|
+
- Security patches only
|
|
63
|
+
- End of support
|
|
64
|
+
|
|
65
|
+
Puma will support any Rack version that still accepts "bug fixes" in addition to security patches. Rack versions that receive only security patches, or are at end of support, are not supported.
|
|
66
|
+
|
|
67
|
+
Due to the need to support "hot" reloading applications (via phased restart) which might have different Rack versions, [Puma cannot directly declare the minimum Rack version](https://github.com/puma/puma/commit/537bc21593182cd9c4c0079a3936d05b1f91fe14). Puma may use runtime or boot time checks to warn or error about Rack version support.
|
|
68
|
+
|
|
69
|
+
## Bundler version support
|
|
70
|
+
|
|
71
|
+
Puma supports the Bundler version that ships with each supported Ruby version.
|
|
72
|
+
|
|
73
|
+
## How to use this document
|
|
74
|
+
|
|
75
|
+
You can use the guidelines here to make suggestions to contributors (anyone reporting an issue, helping with via a comment, or opening a PR) or maintainers. For example, "I could not reproduce your issue using a currently supported Ruby version. Can you please update to version X.Y and verify the issue persists?" Please link to this doc, state what action you're requesting, and why you feel that action is supported by this document. Please act in "good faith" and do not "bikeshed" (the practice of focusing on non-structural or seemingly irrelevant details).
|
|
76
|
+
|
|
77
|
+
## How to update this document?
|
|
78
|
+
|
|
79
|
+
Generally, you shouldn't suggest changes to policies in this document unless you have committed to the Puma project.
|
|
80
|
+
|
|
81
|
+
Non-committers:
|
|
82
|
+
|
|
83
|
+
- Spelling fixes are fine; do not re-grammar or "refactor" the wording.
|
|
84
|
+
- Updating stale details derived from the policies is fine. For example, if a canonical URL changes or if specific upstream versions are listed.
|
|
85
|
+
|
|
86
|
+
Committers:
|
|
87
|
+
|
|
88
|
+
- Suggest whatever policy changes you feel are appropriate.
|
|
89
|
+
- Suggest improvements to the wording or consistency or presentation of information.
|
|
90
|
+
- Do not merge policy changes without oversight of other "significant" contributors.
|
|
91
|
+
- When reviewing a policy change, please mark comments as either blocking or non/blocking. Please try to make blocking comments either satisfiable or falsifiable.
|
|
92
|
+
|
data/docs/rails_dev_mode.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## "Loopback requests"
|
|
4
4
|
|
|
5
|
-
Be cautious of "loopback requests," where a Rails application executes a request to a server that, in turn, results in another request back to the same Rails application before the first request completes. Having a loopback request will trigger [Rails' load interlock](https://guides.rubyonrails.org/threading_and_code_execution.html#load-interlock) mechanism. The load interlock mechanism prevents a thread from using Rails autoloading mechanism to load constants while the application code is still running inside another thread.
|
|
5
|
+
Be cautious of "loopback requests," where a Rails application executes a request to a server that, in turn, results in another request back to the same Rails application before the first request completes. Having a loopback request will trigger [Rails' load interlock](https://guides.rubyonrails.org/threading_and_code_execution.html#load-interlock) mechanism. The load interlock mechanism prevents a thread from using Rails' autoloading mechanism to load constants while the application code is still running inside another thread.
|
|
6
6
|
|
|
7
7
|
This issue only occurs in the development environment as Rails' load interlock is not used in production environments. Although we're not sure, we believe this issue may not occur with the new `zeitwerk` code loader.
|
|
8
8
|
|
|
@@ -25,4 +25,4 @@ do_something_with response
|
|
|
25
25
|
|
|
26
26
|
#### 2. Use multiple processes on Puma
|
|
27
27
|
|
|
28
|
-
Alternatively, you may also enable multiple (single-threaded) workers on Puma. By doing so, you are sidestepping the problem by creating multiple processes rather than new threads. However, this workaround is not ideal because debugging tools such as [byebug](https://github.com/deivid-rodriguez/byebug/issues/487) and [pry](https://github.com/pry/pry/issues/2153)
|
|
28
|
+
Alternatively, you may also enable multiple (single-threaded) workers on Puma. By doing so, you are sidestepping the problem by creating multiple processes rather than new threads. However, this workaround is not ideal because debugging tools such as [byebug](https://github.com/deivid-rodriguez/byebug/issues/487) and [pry](https://github.com/pry/pry/issues/2153) work poorly with any multi-process web server.
|
data/docs/restart.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
# Restart
|
|
2
|
+
|
|
3
|
+
Puma includes the ability to restart itself. When available (MRI, Rubinius, JRuby), Puma performs a "hot restart". This is the same functionality available in *Unicorn* and *NGINX* which keep the server sockets open between restarts. This makes sure that no pending requests are dropped while the restart is taking place.
|
|
4
|
+
|
|
5
|
+
Puma provides three distinct kinds of restart operations, each for different use cases. This document describes "hot restarts" and "phased restarts." The third kind of restart operation is called "refork" and is described in the documentation for [`fork_worker` and `mold_worker`](cluster_mode.md#fork-worker-cluster-mode-experimental).
|
|
2
6
|
|
|
3
7
|
## Hot restart
|
|
4
8
|
|
|
@@ -27,8 +31,9 @@ Any of the following will cause a Puma server to perform a hot restart:
|
|
|
27
31
|
|
|
28
32
|
### Additional notes
|
|
29
33
|
|
|
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.
|
|
34
|
+
* The newly started Puma process changes its current working directory to the directory specified by the `directory` option. If `directory` is set to a symlink, this is automatically re-evaluated, so this mechanism can be used to upgrade the application.
|
|
31
35
|
* Only one version of the application is running at a time.
|
|
36
|
+
* Under systemd with `WatchdogSec` set, the watchdog timer keeps running across a hot restart. Puma pings the watchdog as soon as the new master reports readiness, so `WatchdogSec` needs to exceed your application's boot time.
|
|
32
37
|
* `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
38
|
|
|
34
39
|
## Phased restart
|
|
@@ -57,7 +62,7 @@ Any of the following will cause a Puma server to perform a phased restart:
|
|
|
57
62
|
|
|
58
63
|
### Additional notes
|
|
59
64
|
|
|
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.
|
|
65
|
+
* 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 a symlink, this is automatically re-evaluated, so this mechanism can be used to upgrade the application.
|
|
61
66
|
* On a single server, it's possible that two versions of the application are running concurrently during a phased restart.
|
|
62
67
|
* `before_restart` is not invoked
|
|
63
68
|
* 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.
|
data/docs/signals.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# Signals
|
|
2
|
+
|
|
1
3
|
The [unix signal](https://en.wikipedia.org/wiki/Unix_signal) is a method of sending messages between [processes](https://en.wikipedia.org/wiki/Process_(computing)). When a signal is sent, the operating system interrupts the target process's normal flow of execution. There are standard signals that are used to stop a process, but there are also custom signals that can be used for other purposes. This document is an attempt to list all supported signals that Puma will respond to. In general, signals need only be sent to the master process of a cluster.
|
|
2
4
|
|
|
3
5
|
## Sending Signals
|
|
@@ -40,8 +42,8 @@ Puma cluster responds to these signals:
|
|
|
40
42
|
- `USR1`: Restart workers in phases, a rolling restart. This will not reload the configuration file.
|
|
41
43
|
- `HUP`: Reopen log files defined in `stdout_redirect` configuration parameter. If there is no `stdout_redirect` option provided, it will behave like `INT`.
|
|
42
44
|
- `INT`: Equivalent of sending Ctrl-C to cluster. Puma will attempt to finish then exit.
|
|
43
|
-
- `CHLD`: Reap zombie child processes and wake event loop in `fork_worker`
|
|
44
|
-
- `URG`: Refork workers in phases from worker 0 if `fork_worker` option is enabled.
|
|
45
|
+
- `CHLD`: Reap zombie child processes and wake event loop in `fork_worker` and `mold_worker` modes.
|
|
46
|
+
- `URG`: Refork workers in phases from worker 0 if `fork_worker` option is enabled, or from a newly promoted mold if `mold_worker` option is enabled.
|
|
45
47
|
- `INFO` (or `PWR` for systems without `INFO`) print backtraces of all puma threads (if supported on your platform).
|
|
46
48
|
|
|
47
49
|
## Callbacks order in case of different signals
|
|
@@ -10,7 +10,7 @@ Puma 5 brings new experimental performance features, a few quality-of-life featu
|
|
|
10
10
|
2. Upgrade to version 5.0 in your Gemfile and deploy.
|
|
11
11
|
3. Try the new performance experiments outlined below and report your results back to the Puma issue tracker.
|
|
12
12
|
|
|
13
|
-
Puma 5 was named Spoony Bard by our newest supercontributor, [@wjordan](https://github.com/puma/puma/commits?author=wjordan). Will brought you one of our new perf features for this release, as well as [many other fixes and refactors.](https://github.com/puma/puma/commits?author=wjordan) If you'd like to name a Puma release in the future, take a look at [CONTRIBUTING.md](
|
|
13
|
+
Puma 5 was named Spoony Bard by our newest supercontributor, [@wjordan](https://github.com/puma/puma/commits?author=wjordan). Will brought you one of our new perf features for this release, as well as [many other fixes and refactors.](https://github.com/puma/puma/commits?author=wjordan) If you'd like to name a Puma release in the future, take a look at [CONTRIBUTING.md](../../CONTRIBUTING.md) and get started helping us out :)
|
|
14
14
|
|
|
15
15
|
Puma 5 also welcomes [@MSP-Greg](https://github.com/puma/puma/commits?author=MSP-Greg) as our newest committer. Greg has been instrumental in improving our CI setup and SSL features. Greg also [named our 4.3.0 release](https://github.com/puma/puma/releases/tag/v4.3.0): Mysterious Traveller.
|
|
16
16
|
|
|
@@ -70,7 +70,7 @@ Puma 5 introduces an experimental new cluster-mode configuration option, `fork_w
|
|
|
70
70
|
|
|
71
71
|
It is compatible with phased restarts. It also may improve memory usage because the worker process loads additional code after processing requests.
|
|
72
72
|
|
|
73
|
-
To learn more about using `refork` and `fork_worker`, see ['Fork Worker'](
|
|
73
|
+
To learn more about using `refork` and `fork_worker`, see ['Fork Worker'](../cluster_mode.md#fork-worker-cluster-mode-experimental).
|
|
74
74
|
|
|
75
75
|
### What else is new?
|
|
76
76
|
|
|
@@ -89,7 +89,7 @@ To learn more about using `refork` and `fork_worker`, see ['Fork Worker'](fork_w
|
|
|
89
89
|
* If you have been using the `--control` CLI option, update your scripts to use `--control-url`.
|
|
90
90
|
* If you are using `worker_directory` in your config file, change it to `directory`.
|
|
91
91
|
* If you are running MRI, default thread count on Puma is now 5, not 16. This may change the amount of threads running in your threadpool. We believe 5 is a better default for most Ruby web applications on MRI. Higher settings increase latency by causing GVL contention.
|
|
92
|
-
* If you are using a worker count of more than 1, set using `WEB_CONCURRENCY`, Puma will now preload the application by default (disable with `preload_app! false`). We believe this is a better default, but may cause issues in non-Rails applications if you do not have the proper `before` and `after` fork hooks configured. See documentation for your framework. Rails users do not need to change anything. **Please note that it is not possible to use [the phased restart](restart.md) with preloading.**
|
|
92
|
+
* If you are using a worker count of more than 1, set using `WEB_CONCURRENCY`, Puma will now preload the application by default (disable with `preload_app! false`). We believe this is a better default, but may cause issues in non-Rails applications if you do not have the proper `before` and `after` fork hooks configured. See documentation for your framework. Rails users do not need to change anything. **Please note that it is not possible to use [the phased restart](../restart.md) with preloading.**
|
|
93
93
|
* tcp mode and daemonization have been removed without replacement. For daemonization, please use a modern process management solution, such as systemd or monit.
|
|
94
94
|
* `connected_port` was renamed to `connected_ports` and now returns an Array, not an Integer.
|
|
95
95
|
|
|
@@ -9,9 +9,9 @@ Here's what you should do:
|
|
|
9
9
|
1. Review the Upgrade section below to look for breaking changes that could affect you.
|
|
10
10
|
2. Upgrade to version 6.0 in your Gemfile and deploy.
|
|
11
11
|
3. Open up a new bug issue if you find any problems.
|
|
12
|
-
4. Join us in building Puma! We welcome first-timers. See [CONTRIBUTING.md](
|
|
12
|
+
4. Join us in building Puma! We welcome first-timers. See [CONTRIBUTING.md](../../CONTRIBUTING.md).
|
|
13
13
|
|
|
14
|
-
For a complete list of changes, see [History.md](
|
|
14
|
+
For a complete list of changes, see [History.md](../../History.md).
|
|
15
15
|
|
|
16
16
|
## What's New
|
|
17
17
|
|
|
@@ -27,7 +27,7 @@ We've improved throughput and latency in Puma 6 in a few areas.
|
|
|
27
27
|
|
|
28
28
|
### Experimental Rack 3 Support
|
|
29
29
|
|
|
30
|
-
[Rack 3 is now out](https://github.com/rack/rack/blob/main/UPGRADE-GUIDE.md) and we've started on Rack 3 support. Please open a bug if you find any
|
|
30
|
+
[Rack 3 is now out](https://github.com/rack/rack/blob/main/UPGRADE-GUIDE.md) and we've started on Rack 3 support. Please open a bug if you find any incompatibilities.
|
|
31
31
|
|
|
32
32
|
### Sidekiq 7 Capsules
|
|
33
33
|
|
|
@@ -7,9 +7,9 @@ Here's what you should do:
|
|
|
7
7
|
1. Review the Upgrade section below to look for breaking changes that could affect you.
|
|
8
8
|
2. Upgrade to version 7.0 in your Gemfile and deploy.
|
|
9
9
|
3. Open up a new bug issue if you find any problems.
|
|
10
|
-
4. Join us in building Puma! We welcome first-timers. See [CONTRIBUTING.md](
|
|
10
|
+
4. Join us in building Puma! We welcome first-timers. See [CONTRIBUTING.md](../../CONTRIBUTING.md).
|
|
11
11
|
|
|
12
|
-
For a complete list of changes, see [History.md](
|
|
12
|
+
For a complete list of changes, see [History.md](../../History.md).
|
|
13
13
|
|
|
14
14
|
## What's New
|
|
15
15
|
|
|
@@ -7,9 +7,9 @@ Here's what you should do:
|
|
|
7
7
|
1. Review the Upgrade section below to look for breaking changes that could affect you.
|
|
8
8
|
2. Upgrade to version 8.0 in your Gemfile and deploy.
|
|
9
9
|
3. Open up a new bug issue if you find any problems.
|
|
10
|
-
4. Join us in building Puma! We welcome first-timers. See [CONTRIBUTING.md](
|
|
10
|
+
4. Join us in building Puma! We welcome first-timers. See [CONTRIBUTING.md](../../CONTRIBUTING.md).
|
|
11
11
|
|
|
12
|
-
For a complete list of changes, see [History.md](
|
|
12
|
+
For a complete list of changes, see [History.md](../../History.md).
|
|
13
13
|
|
|
14
14
|
## What's New
|
|
15
15
|
|
|
@@ -33,7 +33,7 @@ run lambda { |env|
|
|
|
33
33
|
}
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
We anticipate this will mainly
|
|
36
|
+
We anticipate this will mainly be used by framework authors who have threads or types of requests they know are extremely IO-bound, and don't recommend it for use at the application level.
|
|
37
37
|
|
|
38
38
|
**Thread pool limits can be changed at runtime.** Puma now exposes `Puma::Server#update_thread_pool_min_max`, and hook/plugin code can do the same through `Puma::ServerPluginControl`.
|
|
39
39
|
|
|
@@ -91,7 +91,7 @@ bind 'tcp://0.0.0.0:9292'
|
|
|
91
91
|
|
|
92
92
|
Check the following list to see if you're depending on any of these behaviors:
|
|
93
93
|
|
|
94
|
-
1. Puma will now listen on `::` (IPv6) by default. Previously, it listened to `0.0.0.0` (IPv4). Systems that support both IPv6 and IPv4 (Ubuntu and Mac commonly do) will still support receiving to `0.0.0.0`. See [
|
|
94
|
+
1. Puma will now listen on `::` (IPv6) by default. Previously, it listened to `0.0.0.0` (IPv4). Systems that support both IPv6 and IPv4 (Ubuntu and Mac commonly do) will still support receiving to `0.0.0.0`. See [the support table in the PR](https://github.com/puma/puma/pull/3847) for binding compatibility. For systems that ONLY bind to IPv6 (without IPv4 support) this may be a breaking change. You can overwrite this default behavior by setting `bind 'tcp://0.0.0.0:9292'`, `port ENV.fetch('PORT', 9292), '0.0.0.0'`, or `set_default_host '0.0.0.0'` explicitly to remain IPv4 only. Review any firewall rules, health checks, deploy scripts, or host-string parsing code that assumed `0.0.0.0`, `127.0.0.1`, or unbracketed `HOST:PORT` formatting.
|
|
95
95
|
2. If you explicitly configure `bind 'tcp://[::]:...'`, `bind 'ssl://[::]:...'`, or equivalent `ssl_bind '::', ...`, Puma will now rewrite that unspecified IPv6 bind to `0.0.0.0` when the host has no non-loopback IPv6 interface, and it will warn on boot. If you were using `::` to force IPv6-only behavior or to detect IPv6 availability, switch to a concrete IPv6 address instead of `::`, or ensure the machine actually has a usable IPv6 interface before Puma starts.
|
|
96
96
|
3. `before_thread_start` hooks now receive a `Puma::ServerPluginControl` argument. Update any zero-arity lambdas, method objects, or other strict-arity hook code to accept one argument, for example `before_thread_start { |_control| ... }`, or Puma can raise `ArgumentError` when the hook runs.
|
|
97
97
|
4. On platforms without `SIGINFO`, Puma now traps `SIGPWR`, and `pumactl info` sends `SIGPWR` there. If your supervisor, init script, or container tooling already uses `SIGPWR` for something else, change that wiring before upgrading and update any runbooks that assumed Puma would ignore `SIGPWR`.
|
data/ext/puma_http11/extconf.rb
CHANGED
|
@@ -592,6 +592,10 @@ case 24:
|
|
|
592
592
|
case 60: goto st0;
|
|
593
593
|
case 62: goto st0;
|
|
594
594
|
case 63: goto tr39;
|
|
595
|
+
case 92: goto st0;
|
|
596
|
+
case 96: goto st0;
|
|
597
|
+
case 123: goto st0;
|
|
598
|
+
case 125: goto st0;
|
|
595
599
|
case 127: goto st0;
|
|
596
600
|
}
|
|
597
601
|
if ( 0 <= (*p) && (*p) <= 31 )
|
|
@@ -607,7 +611,7 @@ st25:
|
|
|
607
611
|
if ( ++p == pe )
|
|
608
612
|
goto _test_eof25;
|
|
609
613
|
case 25:
|
|
610
|
-
#line
|
|
614
|
+
#line 615 "ext/puma_http11/http11_parser.c"
|
|
611
615
|
switch( (*p) ) {
|
|
612
616
|
case 32: goto tr41;
|
|
613
617
|
case 34: goto st0;
|
|
@@ -627,7 +631,7 @@ st26:
|
|
|
627
631
|
if ( ++p == pe )
|
|
628
632
|
goto _test_eof26;
|
|
629
633
|
case 26:
|
|
630
|
-
#line
|
|
634
|
+
#line 635 "ext/puma_http11/http11_parser.c"
|
|
631
635
|
switch( (*p) ) {
|
|
632
636
|
case 32: goto tr44;
|
|
633
637
|
case 34: goto st0;
|
data/ext/puma_http11/mini_ssl.c
CHANGED
|
@@ -228,7 +228,7 @@ sslctx_alloc(VALUE klass) {
|
|
|
228
228
|
VALUE
|
|
229
229
|
sslctx_initialize(VALUE self, VALUE mini_ssl_ctx) {
|
|
230
230
|
SSL_CTX* ctx;
|
|
231
|
-
int ssl_options;
|
|
231
|
+
int ssl_options, private_key_result;
|
|
232
232
|
VALUE key, cert, ca, verify_mode, ssl_cipher_filter, ssl_ciphersuites, no_tlsv1, no_tlsv1_1,
|
|
233
233
|
verification_flags, session_id_bytes, cert_pem, key_pem, key_password_command, key_password;
|
|
234
234
|
BIO *bio;
|
|
@@ -292,15 +292,19 @@ sslctx_initialize(VALUE self, VALUE mini_ssl_ctx) {
|
|
|
292
292
|
StringValue(key_password);
|
|
293
293
|
password_cb = password_callback;
|
|
294
294
|
password = RSTRING_PTR(key_password);
|
|
295
|
-
SSL_CTX_set_default_passwd_cb(ctx, password_cb);
|
|
296
|
-
SSL_CTX_set_default_passwd_cb_userdata(ctx, (void *) password);
|
|
297
295
|
}
|
|
298
296
|
}
|
|
299
297
|
|
|
300
298
|
if (!NIL_P(key)) {
|
|
301
299
|
StringValue(key);
|
|
302
300
|
|
|
303
|
-
|
|
301
|
+
SSL_CTX_set_default_passwd_cb(ctx, password_cb);
|
|
302
|
+
SSL_CTX_set_default_passwd_cb_userdata(ctx, (void *) password);
|
|
303
|
+
private_key_result = SSL_CTX_use_PrivateKey_file(ctx, RSTRING_PTR(key), SSL_FILETYPE_PEM);
|
|
304
|
+
SSL_CTX_set_default_passwd_cb(ctx, NULL);
|
|
305
|
+
SSL_CTX_set_default_passwd_cb_userdata(ctx, NULL);
|
|
306
|
+
|
|
307
|
+
if (private_key_result != 1) {
|
|
304
308
|
raise_file_error("SSL_CTX_use_PrivateKey_file", RSTRING_PTR(key));
|
|
305
309
|
}
|
|
306
310
|
}
|
|
@@ -440,7 +444,14 @@ sslctx_initialize(VALUE self, VALUE mini_ssl_ctx) {
|
|
|
440
444
|
|
|
441
445
|
if (!NIL_P(ssl_cipher_filter)) {
|
|
442
446
|
StringValue(ssl_cipher_filter);
|
|
443
|
-
|
|
447
|
+
ERR_clear_error();
|
|
448
|
+
if (SSL_CTX_set_cipher_list(ctx, RSTRING_PTR(ssl_cipher_filter)) != 1) {
|
|
449
|
+
if (ERR_GET_REASON(ERR_peek_last_error()) == SSL_R_NO_CIPHER_MATCH) {
|
|
450
|
+
ERR_clear_error();
|
|
451
|
+
} else {
|
|
452
|
+
raise_param_error("SSL_CTX_set_cipher_list", "ssl_cipher_filter");
|
|
453
|
+
}
|
|
454
|
+
}
|
|
444
455
|
}
|
|
445
456
|
else {
|
|
446
457
|
SSL_CTX_set_cipher_list(ctx, "HIGH:!aNULL@STRENGTH");
|
|
@@ -596,10 +607,10 @@ VALUE engine_read(VALUE self) {
|
|
|
596
607
|
return rb_str_new(buf, bytes);
|
|
597
608
|
}
|
|
598
609
|
|
|
599
|
-
if(SSL_want_read(conn->ssl)) return Qnil;
|
|
600
|
-
|
|
601
610
|
error = SSL_get_error(conn->ssl, bytes);
|
|
602
611
|
|
|
612
|
+
if(error == SSL_ERROR_WANT_READ) return Qnil;
|
|
613
|
+
|
|
603
614
|
if(error == SSL_ERROR_ZERO_RETURN) {
|
|
604
615
|
rb_eof_error();
|
|
605
616
|
} else {
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
#include <ctype.h>
|
|
14
14
|
#include "http11_parser.h"
|
|
15
15
|
|
|
16
|
+
#ifdef HAVE_PRCTL
|
|
17
|
+
#include <sys/prctl.h>
|
|
18
|
+
#endif
|
|
19
|
+
|
|
16
20
|
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
|
17
21
|
|
|
18
22
|
static VALUE eHttpParserError;
|
|
@@ -385,7 +389,8 @@ static VALUE HttpParser_execute(VALUE self, VALUE req_hash, VALUE data, VALUE st
|
|
|
385
389
|
long dlen = 0;
|
|
386
390
|
|
|
387
391
|
from = FIX2INT(start);
|
|
388
|
-
|
|
392
|
+
dptr = RSTRING_PTR(data);
|
|
393
|
+
dlen = (long)RSTRING_LEN(data);
|
|
389
394
|
|
|
390
395
|
if(from >= dlen) {
|
|
391
396
|
rb_raise(eHttpParserError, "%s", "Requested start is after data buffer end.");
|
|
@@ -398,7 +403,7 @@ static VALUE HttpParser_execute(VALUE self, VALUE req_hash, VALUE data, VALUE st
|
|
|
398
403
|
if(puma_parser_has_error(http)) {
|
|
399
404
|
rb_raise(eHttpParserError, "%s", "Invalid HTTP format, parsing fails. Are you trying to open an SSL connection to a non-SSL Puma?");
|
|
400
405
|
} else {
|
|
401
|
-
return
|
|
406
|
+
return SIZET2NUM(puma_parser_nread(http));
|
|
402
407
|
}
|
|
403
408
|
}
|
|
404
409
|
}
|
|
@@ -444,7 +449,7 @@ static VALUE HttpParser_nread(VALUE self)
|
|
|
444
449
|
{
|
|
445
450
|
puma_parser *http = HttpParser_unwrap(self);
|
|
446
451
|
|
|
447
|
-
return
|
|
452
|
+
return SIZET2NUM(http->nread);
|
|
448
453
|
}
|
|
449
454
|
|
|
450
455
|
/**
|
|
@@ -459,6 +464,24 @@ static VALUE HttpParser_body(VALUE self) {
|
|
|
459
464
|
return http->body;
|
|
460
465
|
}
|
|
461
466
|
|
|
467
|
+
/**
|
|
468
|
+
* call-seq:
|
|
469
|
+
* Puma.enable_child_subreaper -> true or false
|
|
470
|
+
*
|
|
471
|
+
* Marks the calling process as a child subreaper so that orphaned descendants
|
|
472
|
+
* are reparented to it. Returns false where this is unsupported.
|
|
473
|
+
*/
|
|
474
|
+
static VALUE Puma_enable_child_subreaper(VALUE self) {
|
|
475
|
+
#ifdef HAVE_PRCTL
|
|
476
|
+
if (prctl(PR_SET_CHILD_SUBREAPER, 1) < 0) {
|
|
477
|
+
rb_sys_fail("prctl(PR_SET_CHILD_SUBREAPER)");
|
|
478
|
+
}
|
|
479
|
+
return Qtrue;
|
|
480
|
+
#else
|
|
481
|
+
return Qfalse;
|
|
482
|
+
#endif
|
|
483
|
+
}
|
|
484
|
+
|
|
462
485
|
#ifdef HAVE_OPENSSL_BIO_H
|
|
463
486
|
void Init_mini_ssl(VALUE mod);
|
|
464
487
|
#endif
|
|
@@ -482,6 +505,8 @@ RUBY_FUNC_EXPORTED void Init_puma_http11(void)
|
|
|
482
505
|
rb_global_variable(&eHttpParserError);
|
|
483
506
|
eHttpParserError = rb_define_class_under(mPuma, "HttpParserError", rb_eStandardError);
|
|
484
507
|
|
|
508
|
+
rb_define_singleton_method(mPuma, "enable_child_subreaper", Puma_enable_child_subreaper, 0);
|
|
509
|
+
|
|
485
510
|
rb_define_alloc_func(cHttpParser, HttpParser_alloc);
|
|
486
511
|
rb_define_method(cHttpParser, "initialize", HttpParser_init, 0);
|
|
487
512
|
rb_define_method(cHttpParser, "reset", HttpParser_reset, 0);
|
data/lib/puma/binder.rb
CHANGED
|
@@ -309,6 +309,13 @@ module Puma
|
|
|
309
309
|
end
|
|
310
310
|
end
|
|
311
311
|
|
|
312
|
+
# Removes and returns the activated socket for +url+ as <tt>[key, socket]</tt>,
|
|
313
|
+
# or +nil+ if none was activated for it.
|
|
314
|
+
def take_activated_socket(url)
|
|
315
|
+
key = activated_keys_for(url).find { |k| @activated_sockets.key?(k) }
|
|
316
|
+
[key, @activated_sockets.delete(key)] if key
|
|
317
|
+
end
|
|
318
|
+
|
|
312
319
|
def localhost_authority
|
|
313
320
|
@localhost_authority ||= Localhost::Authority.fetch if defined?(Localhost::Authority) && !Puma::IS_JRUBY
|
|
314
321
|
end
|
|
@@ -486,6 +493,28 @@ module Puma
|
|
|
486
493
|
|
|
487
494
|
private
|
|
488
495
|
|
|
496
|
+
def activated_keys_for(url)
|
|
497
|
+
uri = URI.parse url
|
|
498
|
+
case uri.scheme
|
|
499
|
+
when "tcp", "ssl"
|
|
500
|
+
[[:tcp, uri.host, uri.port]]
|
|
501
|
+
when "unix"
|
|
502
|
+
path = "#{uri.host}#{uri.path}".gsub("%20", " ")
|
|
503
|
+
return [] if path.start_with?("@")
|
|
504
|
+
|
|
505
|
+
real_path = begin
|
|
506
|
+
File.realdirpath(path)
|
|
507
|
+
rescue SystemCallError
|
|
508
|
+
path
|
|
509
|
+
end
|
|
510
|
+
[[:unix, path], [:unix, real_path]].uniq
|
|
511
|
+
else
|
|
512
|
+
[]
|
|
513
|
+
end
|
|
514
|
+
rescue URI::InvalidURIError
|
|
515
|
+
[]
|
|
516
|
+
end
|
|
517
|
+
|
|
489
518
|
# @!attribute [r] loopback_addresses
|
|
490
519
|
def loopback_addresses
|
|
491
520
|
t = Socket.ip_address_list.select do |addrinfo|
|
data/lib/puma/cli.rb
CHANGED
|
@@ -138,6 +138,12 @@ module Puma
|
|
|
138
138
|
user_config.fork_worker(*args.compact)
|
|
139
139
|
end
|
|
140
140
|
|
|
141
|
+
o.on "--mold-worker=[REQUESTS]", Array,
|
|
142
|
+
"Fork new workers from a mold promoted from an existing worker. Cluster mode only",
|
|
143
|
+
"Promote a new mold at each comma-separated REQUESTS threshold (default 1000)" do |thresholds|
|
|
144
|
+
user_config.mold_worker(*thresholds)
|
|
145
|
+
end
|
|
146
|
+
|
|
141
147
|
o.on "-I", "--include PATH", "Specify $LOAD_PATH directories" do |arg|
|
|
142
148
|
$LOAD_PATH.unshift(*arg.split(':'))
|
|
143
149
|
end
|