jun-puma 1.0.1-java → 1.0.2-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/lib/puma/puma_http11.jar +0 -0
- metadata +3 -81
- data/bin/puma-wild +0 -25
- data/docs/architecture.md +0 -74
- data/docs/compile_options.md +0 -55
- data/docs/deployment.md +0 -102
- data/docs/fork_worker.md +0 -31
- data/docs/images/puma-connection-flow-no-reactor.png +0 -0
- data/docs/images/puma-connection-flow.png +0 -0
- data/docs/images/puma-general-arch.png +0 -0
- data/docs/jungle/README.md +0 -9
- data/docs/jungle/rc.d/README.md +0 -74
- data/docs/jungle/rc.d/puma +0 -61
- data/docs/jungle/rc.d/puma.conf +0 -10
- data/docs/kubernetes.md +0 -78
- data/docs/nginx.md +0 -80
- data/docs/plugins.md +0 -38
- data/docs/rails_dev_mode.md +0 -28
- data/docs/restart.md +0 -64
- data/docs/signals.md +0 -98
- data/docs/stats.md +0 -142
- data/docs/systemd.md +0 -244
- 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/ext_help.h +0 -15
- data/ext/puma_http11/http11_parser.c +0 -1057
- data/ext/puma_http11/http11_parser.h +0 -65
- data/ext/puma_http11/http11_parser.java.rl +0 -145
- data/ext/puma_http11/http11_parser.rl +0 -149
- data/ext/puma_http11/http11_parser_common.rl +0 -54
- data/ext/puma_http11/mini_ssl.c +0 -832
- data/ext/puma_http11/no_ssl/PumaHttp11Service.java +0 -15
- data/ext/puma_http11/org/jruby/puma/Http11.java +0 -226
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +0 -455
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +0 -508
- data/ext/puma_http11/puma_http11.c +0 -492
- data/lib/puma/app/status.rb +0 -96
- data/lib/puma/binder.rb +0 -501
- data/lib/puma/cli.rb +0 -243
- data/lib/puma/client.rb +0 -632
- data/lib/puma/cluster/worker.rb +0 -182
- data/lib/puma/cluster/worker_handle.rb +0 -97
- data/lib/puma/cluster.rb +0 -562
- data/lib/puma/commonlogger.rb +0 -115
- data/lib/puma/configuration.rb +0 -391
- data/lib/puma/const.rb +0 -289
- data/lib/puma/control_cli.rb +0 -316
- data/lib/puma/detect.rb +0 -45
- data/lib/puma/dsl.rb +0 -1204
- data/lib/puma/error_logger.rb +0 -113
- data/lib/puma/events.rb +0 -57
- data/lib/puma/io_buffer.rb +0 -46
- data/lib/puma/jruby_restart.rb +0 -27
- data/lib/puma/json_serialization.rb +0 -96
- data/lib/puma/launcher/bundle_pruner.rb +0 -104
- data/lib/puma/launcher.rb +0 -484
- data/lib/puma/log_writer.rb +0 -147
- data/lib/puma/minissl/context_builder.rb +0 -95
- data/lib/puma/minissl.rb +0 -458
- data/lib/puma/null_io.rb +0 -61
- data/lib/puma/plugin/systemd.rb +0 -90
- data/lib/puma/plugin/tmp_restart.rb +0 -36
- data/lib/puma/plugin.rb +0 -111
- data/lib/puma/rack/builder.rb +0 -297
- data/lib/puma/rack/urlmap.rb +0 -93
- data/lib/puma/rack_default.rb +0 -24
- data/lib/puma/reactor.rb +0 -125
- data/lib/puma/request.rb +0 -671
- data/lib/puma/runner.rb +0 -213
- data/lib/puma/sd_notify.rb +0 -149
- data/lib/puma/server.rb +0 -664
- data/lib/puma/single.rb +0 -69
- data/lib/puma/state_file.rb +0 -68
- data/lib/puma/thread_pool.rb +0 -434
- data/lib/puma/util.rb +0 -141
- data/lib/puma.rb +0 -78
- data/lib/rack/handler/puma.rb +0 -141
- data/tools/Dockerfile +0 -16
- data/tools/trickletest.rb +0 -44
data/docs/nginx.md
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
# Nginx configuration example file
|
2
|
-
|
3
|
-
This is a very common setup using an upstream. It was adapted from some Capistrano recipe I found on the Internet a while ago.
|
4
|
-
|
5
|
-
```nginx
|
6
|
-
upstream myapp {
|
7
|
-
server unix:///myapp/tmp/puma.sock;
|
8
|
-
}
|
9
|
-
|
10
|
-
server {
|
11
|
-
listen 80;
|
12
|
-
server_name myapp.com;
|
13
|
-
|
14
|
-
# ~2 seconds is often enough for most folks to parse HTML/CSS and
|
15
|
-
# retrieve needed images/icons/frames, connections are cheap in
|
16
|
-
# nginx so increasing this is generally safe...
|
17
|
-
keepalive_timeout 5;
|
18
|
-
|
19
|
-
# path for static files
|
20
|
-
root /myapp/public;
|
21
|
-
access_log /myapp/log/nginx.access.log;
|
22
|
-
error_log /myapp/log/nginx.error.log info;
|
23
|
-
|
24
|
-
# this rewrites all the requests to the maintenance.html
|
25
|
-
# page if it exists in the doc root. This is for capistrano's
|
26
|
-
# disable web task
|
27
|
-
if (-f $document_root/maintenance.html) {
|
28
|
-
rewrite ^(.*)$ /maintenance.html last;
|
29
|
-
break;
|
30
|
-
}
|
31
|
-
|
32
|
-
location / {
|
33
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
34
|
-
proxy_set_header Host $host;
|
35
|
-
|
36
|
-
# If the file exists as a static file serve it directly without
|
37
|
-
# running all the other rewrite tests on it
|
38
|
-
if (-f $request_filename) {
|
39
|
-
break;
|
40
|
-
}
|
41
|
-
|
42
|
-
# check for index.html for directory index
|
43
|
-
# if it's there on the filesystem then rewrite
|
44
|
-
# the url to add /index.html to the end of it
|
45
|
-
# and then break to send it to the next config rules.
|
46
|
-
if (-f $request_filename/index.html) {
|
47
|
-
rewrite (.*) $1/index.html break;
|
48
|
-
}
|
49
|
-
|
50
|
-
# this is the meat of the rack page caching config
|
51
|
-
# it adds .html to the end of the url and then checks
|
52
|
-
# the filesystem for that file. If it exists, then we
|
53
|
-
# rewrite the url to have explicit .html on the end
|
54
|
-
# and then send it on its way to the next config rule.
|
55
|
-
# if there is no file on the fs then it sets all the
|
56
|
-
# necessary headers and proxies to our upstream pumas
|
57
|
-
if (-f $request_filename.html) {
|
58
|
-
rewrite (.*) $1.html break;
|
59
|
-
}
|
60
|
-
|
61
|
-
if (!-f $request_filename) {
|
62
|
-
proxy_pass http://myapp;
|
63
|
-
break;
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
|
-
# Now this supposedly should work as it gets the filenames with querystrings that Rails provides.
|
68
|
-
# BUT there's a chance it could break the ajax calls.
|
69
|
-
location ~* \.(ico|css|gif|jpe?g|png|js)(\?[0-9]+)?$ {
|
70
|
-
expires max;
|
71
|
-
break;
|
72
|
-
}
|
73
|
-
|
74
|
-
# Error pages
|
75
|
-
# error_page 500 502 503 504 /500.html;
|
76
|
-
location = /500.html {
|
77
|
-
root /myapp/current/public;
|
78
|
-
}
|
79
|
-
}
|
80
|
-
```
|
data/docs/plugins.md
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
## Plugins
|
2
|
-
|
3
|
-
Puma 3.0 added support for plugins that can augment configuration and service
|
4
|
-
operations.
|
5
|
-
|
6
|
-
There are two canonical plugins to aid in the development of new plugins:
|
7
|
-
|
8
|
-
* [tmp\_restart](https://github.com/puma/puma/blob/master/lib/puma/plugin/tmp_restart.rb):
|
9
|
-
Restarts the server if the file `tmp/restart.txt` is touched
|
10
|
-
* [heroku](https://github.com/puma/puma-heroku/blob/master/lib/puma/plugin/heroku.rb):
|
11
|
-
Packages up the default configuration used by Puma on Heroku (being sunset
|
12
|
-
with the release of Puma 5.0)
|
13
|
-
|
14
|
-
Plugins are activated in a Puma configuration file (such as `config/puma.rb'`)
|
15
|
-
by adding `plugin "name"`, such as `plugin "heroku"`.
|
16
|
-
|
17
|
-
Plugins are activated based on path requirements so, activating the `heroku`
|
18
|
-
plugin is much like `require "puma/plugin/heroku"`. This allows gems to provide
|
19
|
-
multiple plugins (as well as unrelated gems to provide Puma plugins).
|
20
|
-
|
21
|
-
The `tmp_restart` plugin comes with Puma, so it is always available.
|
22
|
-
|
23
|
-
To use the `heroku` plugin, add `puma-heroku` to your Gemfile or install it.
|
24
|
-
|
25
|
-
### API
|
26
|
-
|
27
|
-
## Server-wide hooks
|
28
|
-
|
29
|
-
Plugins can use a couple of hooks at the server level: `start` and `config`.
|
30
|
-
|
31
|
-
`start` runs when the server has started and allows the plugin to initiate other
|
32
|
-
functionality to augment Puma.
|
33
|
-
|
34
|
-
`config` runs when the server is being configured and receives a `Puma::DSL`
|
35
|
-
object that is useful for additional configuration.
|
36
|
-
|
37
|
-
Public methods in [`Puma::Plugin`](../lib/puma/plugin.rb) are treated as a
|
38
|
-
public API for plugins.
|
data/docs/rails_dev_mode.md
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# Running Puma in Rails Development Mode
|
2
|
-
|
3
|
-
## "Loopback requests"
|
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.
|
6
|
-
|
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
|
-
|
9
|
-
### Solutions
|
10
|
-
|
11
|
-
#### 1. Bypass Rails' load interlock with `.permit_concurrent_loads`
|
12
|
-
|
13
|
-
Wrap the first request inside a block that will allow concurrent loads: [`ActiveSupport::Dependencies.interlock.permit_concurrent_loads`](https://guides.rubyonrails.org/threading_and_code_execution.html#permit-concurrent-loads). Anything wrapped inside the `.permit_concurrent_loads` block will bypass the load interlock mechanism, allowing new threads to access the Rails environment and boot properly.
|
14
|
-
|
15
|
-
###### Example
|
16
|
-
|
17
|
-
```ruby
|
18
|
-
response = ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
|
19
|
-
# Your HTTP request code here. For example:
|
20
|
-
Faraday.post url, data: 'foo'
|
21
|
-
end
|
22
|
-
|
23
|
-
do_something_with response
|
24
|
-
```
|
25
|
-
|
26
|
-
#### 2. Use multiple processes on Puma
|
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), work poorly with any multi-process web server.
|
data/docs/restart.md
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
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`](fork_worker.md).
|
2
|
-
|
3
|
-
## Hot restart
|
4
|
-
|
5
|
-
To perform a "hot" restart, Puma performs an `exec` operation to start the process up again, so no memory is shared between the old process and the new process. As a result, it is safe to issue a restart at any place where you would manually stop Puma and start it again. In particular, it is safe to upgrade Puma itself using a hot restart.
|
6
|
-
|
7
|
-
If the new process is unable to load, it will simply exit. You should therefore run Puma under a process monitor when using it in production.
|
8
|
-
|
9
|
-
### How-to
|
10
|
-
|
11
|
-
Any of the following will cause a Puma server to perform a hot restart:
|
12
|
-
|
13
|
-
* Send the `puma` process the `SIGUSR2` signal
|
14
|
-
* Issue a `GET` request to the Puma status/control server with the path `/restart`
|
15
|
-
* Issue `pumactl restart` (this uses the control server method if available, otherwise sends the `SIGUSR2` signal to the process)
|
16
|
-
|
17
|
-
### Supported configurations
|
18
|
-
|
19
|
-
* Works in cluster mode and single mode
|
20
|
-
* Supported on all platforms
|
21
|
-
|
22
|
-
### Client experience
|
23
|
-
|
24
|
-
* All platforms: clients with an in-flight request are served responses before the connection is closed gracefully. Puma gracefully disconnects any idle HTTP persistent connections before restarting.
|
25
|
-
* On MRI or TruffleRuby on Linux and BSD: Clients who connect just before the server restarts may experience increased latency while the server stops and starts again, but their connections will not be closed prematurely.
|
26
|
-
* On Windows and JRuby: Clients who connect just before a restart may experience "connection reset" errors.
|
27
|
-
|
28
|
-
### Additional notes
|
29
|
-
|
30
|
-
* Only one version of the application is running at a time.
|
31
|
-
* `on_restart` is invoked just before the server shuts down. This can be used to clean up resources (like long-lived database connections) gracefully. Since Ruby 2.0, it is not typically necessary to explicitly close file descriptors on restart. This is because any file descriptor opened by Ruby will have the `FD_CLOEXEC` flag set, meaning that file descriptors are closed on `exec`. `on_restart` is useful, though, if your application needs to perform any more graceful protocol-specific shutdown procedures before closing connections.
|
32
|
-
|
33
|
-
## Phased restart
|
34
|
-
|
35
|
-
Phased restarts replace all running workers in a Puma cluster. This is a useful way to upgrade the application that Puma is serving gracefully. A phased restart works by first killing an old worker, then starting a new worker, waiting until the new worker has successfully started before proceeding to the next worker. This process continues until all workers are replaced. The master process is not restarted.
|
36
|
-
|
37
|
-
### How-to
|
38
|
-
|
39
|
-
Any of the following will cause a Puma server to perform a phased restart:
|
40
|
-
|
41
|
-
* Send the `puma` process the `SIGUSR1` signal
|
42
|
-
* Issue a `GET` request to the Puma status/control server with the path `/phased-restart`
|
43
|
-
* Issue `pumactl phased-restart` (this uses the control server method if available, otherwise sends the `SIGUSR1` signal to the process)
|
44
|
-
|
45
|
-
### Supported configurations
|
46
|
-
|
47
|
-
* Works in cluster mode only
|
48
|
-
* To support upgrading the application that Puma is serving, ensure `prune_bundler` is enabled and that `preload_app!` is disabled
|
49
|
-
* Supported on all platforms where cluster mode is supported
|
50
|
-
|
51
|
-
### Client experience
|
52
|
-
|
53
|
-
* In-flight requests are always served responses before the connection is closed gracefully
|
54
|
-
* Idle persistent connections are gracefully disconnected
|
55
|
-
* New connections are not lost, and clients will not experience any increase in latency (as long as the number of configured workers is greater than one)
|
56
|
-
|
57
|
-
### Additional notes
|
58
|
-
|
59
|
-
* 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.
|
60
|
-
* On a single server, it's possible that two versions of the application are running concurrently during a phased restart.
|
61
|
-
* `on_restart` is not invoked
|
62
|
-
* 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.
|
63
|
-
* 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.
|
64
|
-
* 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
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
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
|
-
|
3
|
-
## Sending Signals
|
4
|
-
|
5
|
-
If you are new to signals, it can be helpful to see how they are used. When a process starts in a *nix-like operating system, it will have a [PID - or process identifier](https://en.wikipedia.org/wiki/Process_identifier) that can be used to send signals to the process. For demonstration, we will create an infinitely running process by tailing a file:
|
6
|
-
|
7
|
-
```sh
|
8
|
-
$ echo "foo" >> my.log
|
9
|
-
$ irb
|
10
|
-
> pid = Process.spawn 'tail -f my.log'
|
11
|
-
```
|
12
|
-
|
13
|
-
From here, we can see that the tail process is running by using the `ps` command:
|
14
|
-
|
15
|
-
```sh
|
16
|
-
$ ps aux | grep tail
|
17
|
-
schneems 87152 0.0 0.0 2432772 492 s032 S+ 12:46PM 0:00.00 tail -f my.log
|
18
|
-
```
|
19
|
-
|
20
|
-
You can send a signal in Ruby using the [Process module](https://www.ruby-doc.org/core-2.1.1/Process.html#kill-method):
|
21
|
-
|
22
|
-
```
|
23
|
-
$ irb
|
24
|
-
> puts pid
|
25
|
-
=> 87152
|
26
|
-
Process.detach(pid) # https://ruby-doc.org/core-2.1.1/Process.html#method-c-detach
|
27
|
-
Process.kill("TERM", pid)
|
28
|
-
```
|
29
|
-
|
30
|
-
Now you will see via `ps` that there is no more `tail` process. Sometimes when referring to signals, the `SIG` prefix will be used. For example, `SIGTERM` is equivalent to sending `TERM` via `Process.kill`.
|
31
|
-
|
32
|
-
## Puma Signals
|
33
|
-
|
34
|
-
Puma cluster responds to these signals:
|
35
|
-
|
36
|
-
- `TTIN` increment the worker count by 1
|
37
|
-
- `TTOU` decrement the worker count by 1
|
38
|
-
- `TERM` send `TERM` to worker. The worker will attempt to finish then exit.
|
39
|
-
- `USR2` restart workers. This also reloads the Puma configuration file, if there is one.
|
40
|
-
- `USR1` restart workers in phases, a rolling restart. This will not reload the configuration file.
|
41
|
-
- `HUP ` reopen log files defined in stdout_redirect configuration parameter. If there is no stdout_redirect option provided, it will behave like `INT`
|
42
|
-
- `INT ` equivalent of sending Ctrl-C to cluster. Puma will attempt to finish then exit.
|
43
|
-
- `CHLD`
|
44
|
-
- `URG ` refork workers in phases from worker 0 if `fork_workers` option is enabled.
|
45
|
-
- `INFO` print backtraces of all puma threads
|
46
|
-
|
47
|
-
## Callbacks order in case of different signals
|
48
|
-
|
49
|
-
### Start application
|
50
|
-
|
51
|
-
```
|
52
|
-
puma configuration file reloaded, if there is one
|
53
|
-
* Pruning Bundler environment
|
54
|
-
puma configuration file reloaded, if there is one
|
55
|
-
|
56
|
-
before_fork
|
57
|
-
on_worker_fork
|
58
|
-
after_worker_fork
|
59
|
-
|
60
|
-
Gemfile in context
|
61
|
-
|
62
|
-
on_worker_boot
|
63
|
-
|
64
|
-
Code of the app is loaded and running
|
65
|
-
```
|
66
|
-
|
67
|
-
### Send USR2
|
68
|
-
|
69
|
-
```
|
70
|
-
on_worker_shutdown
|
71
|
-
on_restart
|
72
|
-
|
73
|
-
puma configuration file reloaded, if there is one
|
74
|
-
|
75
|
-
before_fork
|
76
|
-
on_worker_fork
|
77
|
-
after_worker_fork
|
78
|
-
|
79
|
-
Gemfile in context
|
80
|
-
|
81
|
-
on_worker_boot
|
82
|
-
|
83
|
-
Code of the app is loaded and running
|
84
|
-
```
|
85
|
-
|
86
|
-
### Send USR1
|
87
|
-
|
88
|
-
```
|
89
|
-
on_worker_shutdown
|
90
|
-
on_worker_fork
|
91
|
-
after_worker_fork
|
92
|
-
|
93
|
-
Gemfile in context
|
94
|
-
|
95
|
-
on_worker_boot
|
96
|
-
|
97
|
-
Code of the app is loaded and running
|
98
|
-
```
|
data/docs/stats.md
DELETED
@@ -1,142 +0,0 @@
|
|
1
|
-
## Accessing stats
|
2
|
-
|
3
|
-
Stats can be accessed in two ways:
|
4
|
-
|
5
|
-
### control server
|
6
|
-
|
7
|
-
`$ pumactl stats` or `GET /stats`
|
8
|
-
|
9
|
-
[Read more about `pumactl` and the control server in the README.](https://github.com/puma/puma#controlstatus-server).
|
10
|
-
|
11
|
-
### Puma.stats
|
12
|
-
|
13
|
-
`Puma.stats` produces a JSON string. `Puma.stats_hash` produces a ruby hash.
|
14
|
-
|
15
|
-
#### in single mode
|
16
|
-
|
17
|
-
Invoke `Puma.stats` anywhere in runtime, e.g. in a rails initializer:
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
# config/initializers/puma_stats.rb
|
21
|
-
|
22
|
-
Thread.new do
|
23
|
-
loop do
|
24
|
-
sleep 30
|
25
|
-
puts Puma.stats
|
26
|
-
end
|
27
|
-
end
|
28
|
-
```
|
29
|
-
|
30
|
-
#### in cluster mode
|
31
|
-
|
32
|
-
Invoke `Puma.stats` from the master process
|
33
|
-
|
34
|
-
```ruby
|
35
|
-
# config/puma.rb
|
36
|
-
|
37
|
-
before_fork do
|
38
|
-
Thread.new do
|
39
|
-
loop do
|
40
|
-
puts Puma.stats
|
41
|
-
sleep 30
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
```
|
46
|
-
|
47
|
-
|
48
|
-
## Explanation of stats
|
49
|
-
|
50
|
-
`Puma.stats` returns different information and a different structure depending on if Puma is in single vs. cluster mode. There is one top-level attribute that is common to both modes:
|
51
|
-
|
52
|
-
* started_at: when Puma was started
|
53
|
-
|
54
|
-
### single mode and individual workers in cluster mode
|
55
|
-
|
56
|
-
When Puma runs in single mode, these stats are available at the top level. When Puma runs in cluster mode, these stats are available within the `worker_status` array in a hash labeled `last_status`, in an array of hashes where one hash represents each worker.
|
57
|
-
|
58
|
-
* backlog: requests that are waiting for an available thread to be available. if this is above 0, you need more capacity [always true?]
|
59
|
-
* running: how many threads are running
|
60
|
-
* pool_capacity: the number of requests that the server is capable of taking right now. For example, if the number is 5, then it means there are 5 threads sitting idle ready to take a request. If one request comes in, then the value would be 4 until it finishes processing. If the minimum threads allowed is zero, this number will still have a maximum value of the maximum threads allowed.
|
61
|
-
* max_threads: the maximum number of threads Puma is configured to spool per worker
|
62
|
-
* requests_count: the number of requests this worker has served since starting
|
63
|
-
|
64
|
-
|
65
|
-
### cluster mode
|
66
|
-
|
67
|
-
* phase: which phase of restart the process is in, during [phased restart](https://github.com/puma/puma/blob/master/docs/restart.md)
|
68
|
-
* workers: ??
|
69
|
-
* booted_workers: how many workers currently running?
|
70
|
-
* old_workers: ??
|
71
|
-
* worker_status: array of hashes of info for each worker (see below)
|
72
|
-
|
73
|
-
### worker status
|
74
|
-
|
75
|
-
* started_at: when the worker started
|
76
|
-
* pid: the process id of the worker process
|
77
|
-
* index: each worker gets a number. if Puma is configured to have 3 workers, then this will be 0, 1, or 2
|
78
|
-
* booted: if it's done booting [?]
|
79
|
-
* last_checkin: Last time the worker responded to the master process' heartbeat check.
|
80
|
-
* last_status: a hash of info about the worker's state handling requests. See the explanation for this in "single mode and individual workers in cluster mode" section above.
|
81
|
-
|
82
|
-
|
83
|
-
## Examples
|
84
|
-
|
85
|
-
Here are two example stats hashes produced by `Puma.stats`:
|
86
|
-
|
87
|
-
### single
|
88
|
-
|
89
|
-
```json
|
90
|
-
{
|
91
|
-
"started_at": "2021-01-14T07:12:35Z",
|
92
|
-
"backlog": 0,
|
93
|
-
"running": 5,
|
94
|
-
"pool_capacity": 5,
|
95
|
-
"max_threads": 5,
|
96
|
-
"requests_count": 3
|
97
|
-
}
|
98
|
-
```
|
99
|
-
|
100
|
-
### cluster
|
101
|
-
|
102
|
-
```json
|
103
|
-
{
|
104
|
-
"started_at": "2021-01-14T07:09:17Z",
|
105
|
-
"workers": 2,
|
106
|
-
"phase": 0,
|
107
|
-
"booted_workers": 2,
|
108
|
-
"old_workers": 0,
|
109
|
-
"worker_status": [
|
110
|
-
{
|
111
|
-
"started_at": "2021-01-14T07:09:24Z",
|
112
|
-
"pid": 64136,
|
113
|
-
"index": 0,
|
114
|
-
"phase": 0,
|
115
|
-
"booted": true,
|
116
|
-
"last_checkin": "2021-01-14T07:11:09Z",
|
117
|
-
"last_status": {
|
118
|
-
"backlog": 0,
|
119
|
-
"running": 5,
|
120
|
-
"pool_capacity": 5,
|
121
|
-
"max_threads": 5,
|
122
|
-
"requests_count": 2
|
123
|
-
}
|
124
|
-
},
|
125
|
-
{
|
126
|
-
"started_at": "2021-01-14T07:09:24Z",
|
127
|
-
"pid": 64137,
|
128
|
-
"index": 1,
|
129
|
-
"phase": 0,
|
130
|
-
"booted": true,
|
131
|
-
"last_checkin": "2021-01-14T07:11:09Z",
|
132
|
-
"last_status": {
|
133
|
-
"backlog": 0,
|
134
|
-
"running": 5,
|
135
|
-
"pool_capacity": 5,
|
136
|
-
"max_threads": 5,
|
137
|
-
"requests_count": 1
|
138
|
-
}
|
139
|
-
}
|
140
|
-
]
|
141
|
-
}
|
142
|
-
```
|