puma 4.0.1 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puma might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/History.md +66 -3
- data/README.md +67 -39
- data/docs/plugins.md +20 -10
- data/ext/puma_http11/http11_parser.c +37 -62
- data/ext/puma_http11/http11_parser_common.rl +3 -3
- data/ext/puma_http11/mini_ssl.c +55 -7
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +4 -0
- data/lib/puma.rb +8 -0
- data/lib/puma/accept_nonblock.rb +7 -1
- data/lib/puma/app/status.rb +33 -28
- data/lib/puma/binder.rb +37 -12
- data/lib/puma/cli.rb +4 -0
- data/lib/puma/client.rb +197 -193
- data/lib/puma/cluster.rb +45 -46
- data/lib/puma/configuration.rb +2 -2
- data/lib/puma/const.rb +18 -18
- data/lib/puma/control_cli.rb +11 -4
- data/lib/puma/dsl.rb +261 -81
- data/lib/puma/events.rb +4 -1
- data/lib/puma/launcher.rb +90 -47
- data/lib/puma/minissl.rb +25 -19
- data/lib/puma/plugin.rb +5 -2
- data/lib/puma/plugin/tmp_restart.rb +2 -0
- data/lib/puma/rack/builder.rb +2 -0
- data/lib/puma/rack/urlmap.rb +2 -0
- data/lib/puma/rack_default.rb +2 -0
- data/lib/puma/reactor.rb +6 -5
- data/lib/puma/runner.rb +4 -3
- data/lib/puma/server.rb +33 -23
- data/lib/puma/single.rb +1 -1
- data/lib/puma/thread_pool.rb +9 -31
- data/lib/rack/handler/puma.rb +3 -3
- data/tools/docker/Dockerfile +16 -0
- data/tools/jungle/init.d/puma +1 -1
- data/tools/trickletest.rb +0 -1
- metadata +4 -4
- data/lib/puma/daemon_ext.rb +0 -33
- data/lib/puma/delegation.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9951b68e8fbc1851402ee152ae08df16681868b48cb8dd1ab94c409b12125b2
|
4
|
+
data.tar.gz: 250163367ab0f96dc67feb73e1105c48d20d69d5ad77095ce741d5ac63927e79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58c353b21da37a71ca1cca25f75ebc70bba0c1db97a3384d0169fb8258f5952a0ce80260330492fd7767d9ab423a834afd399d3ef1035cbbc248b0d767af8f06
|
7
|
+
data.tar.gz: 8143eeaccf5b22c0d99e2eb3c2852278833a927d31c6f7e7ed333866f3ce9753b67fe6b3dfd447078cae1269606075c2977a8d389b4169cc3738feacdf28c5db
|
data/History.md
CHANGED
@@ -1,16 +1,72 @@
|
|
1
|
-
## Master
|
2
|
-
|
3
1
|
* Features
|
4
2
|
* Your feature goes here (#Github Number)
|
5
3
|
|
6
4
|
* Bugfixes
|
7
5
|
* Your bugfix goes here (#Github Number)
|
8
6
|
|
7
|
+
## 4.2.1 / 2019-10-07
|
8
|
+
|
9
|
+
* 3 bugfixes
|
10
|
+
* Fix socket activation of systemd (pre-existing) unix binder files (#1842, #1988)
|
11
|
+
* Deal with multiple calls to bind correctly (#1986, #1994, #2006)
|
12
|
+
* Accepts symbols for `verify_mode` (#1222)
|
13
|
+
|
14
|
+
## 4.2.0 / 2019-09-23
|
15
|
+
|
16
|
+
* 6 features
|
17
|
+
* Pumactl has a new -e environment option and reads config/puma/<environment>.rb config files (#1885)
|
18
|
+
* Semicolons are now allowed in URL paths (MRI only), useful for Angular or Redmine (#1934)
|
19
|
+
* Allow extra dependencies to be defined when using prune_bundler (#1105)
|
20
|
+
* Puma now reports the correct port when binding to port 0, also reports other listeners when binding to localhost (#1786)
|
21
|
+
* Sending SIGINFO to any Puma worker now prints currently active threads and their backtraces (#1320)
|
22
|
+
* Puma threads all now have their name set on Ruby 2.3+ (#1968)
|
23
|
+
* 4 bugfixes
|
24
|
+
* Fix some misbehavior with phased restart and externally SIGTERMed workers (#1908, #1952)
|
25
|
+
* Fix socket closing on error (#1941)
|
26
|
+
* Removed unnecessary SIGINT trap for JRuby that caused some race conditions (#1961)
|
27
|
+
* Fix socket files being left around after process stopped (#1970)
|
28
|
+
* Absolutely thousands of lines of test improvements and fixes thanks to @MSP-Greg
|
29
|
+
|
30
|
+
## 4.1.1 / 2019-09-05
|
31
|
+
|
32
|
+
* 3 bugfixes
|
33
|
+
* Revert our attempt to not dup STDOUT/STDERR (#1946)
|
34
|
+
* Fix socket close on error (#1941)
|
35
|
+
* Fix workers not shutting down correctly (#1908)
|
36
|
+
|
37
|
+
## 4.1.0 / 2019-08-08
|
38
|
+
|
39
|
+
* 4 features
|
40
|
+
* Add REQUEST_PATH on parse error message (#1831)
|
41
|
+
* You can now easily add custom log formatters with the `log_formatter` config option (#1816)
|
42
|
+
* Puma.stats now provides process start times (#1844)
|
43
|
+
* Add support for disabling TLSv1.1 (#1836)
|
44
|
+
|
45
|
+
* 7 bugfixes
|
46
|
+
* Fix issue where Puma was creating zombie process entries (#1887)
|
47
|
+
* Fix bugs with line-endings and chunked encoding (#1812)
|
48
|
+
* RACK_URL_SCHEME is now set correctly in all conditions (#1491)
|
49
|
+
* We no longer mutate global STDOUT/STDERR, particularly the sync setting (#1837)
|
50
|
+
* SSL read_nonblock no longer blocks (#1857)
|
51
|
+
* Swallow connection errors when sending early hints (#1822)
|
52
|
+
* Backtrace no longer dumped when invalid pumactl commands are run (#1863)
|
53
|
+
|
54
|
+
* 5 other
|
55
|
+
* Avoid casting worker_timeout twice (#1838)
|
56
|
+
* Removed a call to private that wasn't doing anything (#1882)
|
57
|
+
* README, Rakefile, docs and test cleanups (#1848, #1847, #1846, #1853, #1859, #1850, #1866, #1870, #1872, #1833, #1888)
|
58
|
+
* Puma.io has proper documentation now (https://puma.io/puma/)
|
59
|
+
* Added the Contributor Covenant CoC
|
60
|
+
|
61
|
+
* 1 known issue
|
62
|
+
* Some users are still experiencing issues surrounding socket activation and Unix sockets (#1842)
|
63
|
+
|
9
64
|
## 4.0.1 / 2019-07-11
|
10
65
|
|
11
66
|
* 2 bugfixes
|
12
67
|
* Fix socket removed after reload - should fix problems with systemd socket activation. (#1829)
|
13
68
|
* Add extconf tests for DTLS_method & TLS_server_method, use in minissl.rb. Should fix "undefined symbol: DTLS_method" when compiling against old OpenSSL versions. (#1832)
|
69
|
+
* 1 other
|
14
70
|
* Removed unnecessary RUBY_VERSION checks. (#1827)
|
15
71
|
|
16
72
|
## 4.0.0 / 2019-06-25
|
@@ -26,7 +82,7 @@
|
|
26
82
|
* Reactor now uses nio4r instead of `select` (#1728)
|
27
83
|
* Add status to pumactl with pidfile (#1824)
|
28
84
|
|
29
|
-
*
|
85
|
+
* 10 bugfixes
|
30
86
|
* Do not accept new requests on shutdown (#1685, #1808)
|
31
87
|
* Fix 3 corner cases when request body is chunked (#1508)
|
32
88
|
* Change pid existence check's condition branches (#1650)
|
@@ -36,6 +92,13 @@
|
|
36
92
|
* Fix Java 8 support (#1773)
|
37
93
|
* Fix error `uninitialized constant Puma::Cluster` (#1731)
|
38
94
|
* Fix `not_token` being able to be set to true (#1803)
|
95
|
+
* Fix "Hang on SIGTERM with ruby 2.6 in clustered mode" ([PR #1741], [#1674], [#1720], [#1730], [#1755])
|
96
|
+
|
97
|
+
[PR #1741]: https://github.com/puma/puma/pull/1741
|
98
|
+
[#1674]: https://github.com/puma/puma/issues/1674
|
99
|
+
[#1720]: https://github.com/puma/puma/issues/1720
|
100
|
+
[#1730]: https://github.com/puma/puma/issues/1730
|
101
|
+
[#1755]: https://github.com/puma/puma/issues/1755
|
39
102
|
|
40
103
|
## 3.12.1 / 2019-03-19
|
41
104
|
|
data/README.md
CHANGED
@@ -5,41 +5,43 @@
|
|
5
5
|
# Puma: A Ruby Web Server Built For Concurrency
|
6
6
|
|
7
7
|
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/puma/puma?utm\_source=badge&utm\_medium=badge&utm\_campaign=pr-badge)
|
8
|
-
[![Travis Build Status](https://
|
9
|
-
|
8
|
+
[![Travis Build Status](https://travis-ci.org/puma/puma.svg?branch=master)](https://travis-ci.org/puma/puma)
|
9
|
+
|
10
10
|
[![Code Climate](https://codeclimate.com/github/puma/puma.svg)](https://codeclimate.com/github/puma/puma)
|
11
11
|
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=puma&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=puma&package-manager=bundler&version-scheme=semver)
|
12
12
|
|
13
|
-
Puma is a **simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications
|
13
|
+
Puma is a **simple, fast, multi-threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications**.
|
14
14
|
|
15
15
|
## Built For Speed & Concurrency
|
16
16
|
|
17
|
-
|
17
|
+
Puma processes requests using a C-optimized Ragel extension (inherited from Mongrel) that provides fast, accurate HTTP 1.1 protocol parsing in a portable way. Puma then serves the request using a thread pool. Each request is served in a separate thread, so truly concurrent Ruby implementations (JRuby, Rubinius) will use all available CPU cores.
|
18
18
|
|
19
|
-
Puma was designed to be the go-to server for [Rubinius](https://
|
19
|
+
Puma was designed to be the go-to server for [Rubinius](https://rubinius.com), but also works well with JRuby and MRI.
|
20
20
|
|
21
|
-
On MRI, there is a Global VM Lock (GVL) that ensures only one thread can run Ruby code at a time. But if you're doing a lot of blocking IO (such as HTTP calls to external APIs like Twitter), Puma still improves MRI's throughput by allowing
|
21
|
+
On MRI, there is a Global VM Lock (GVL) that ensures only one thread can run Ruby code at a time. But if you're doing a lot of blocking IO (such as HTTP calls to external APIs like Twitter), Puma still improves MRI's throughput by allowing IO waiting to be done in parallel.
|
22
22
|
|
23
23
|
## Quick Start
|
24
24
|
|
25
25
|
```
|
26
26
|
$ gem install puma
|
27
|
-
$ puma
|
27
|
+
$ puma
|
28
28
|
```
|
29
29
|
|
30
|
+
Without arguments, puma will look for a rackup (.ru) file in the current working directory called `config.ru`.
|
31
|
+
|
30
32
|
## Frameworks
|
31
33
|
|
32
34
|
### Rails
|
33
35
|
|
34
|
-
Puma is the default server for Rails,
|
36
|
+
Puma is the default server for Rails, included in the generated Gemfile.
|
35
37
|
|
36
|
-
|
38
|
+
Start your server with the `rails` command:
|
37
39
|
|
38
40
|
```
|
39
|
-
$ rails
|
41
|
+
$ rails server
|
40
42
|
```
|
41
43
|
|
42
|
-
Many configuration options are not available when using `rails
|
44
|
+
Many configuration options and Puma features are not available when using `rails server`. It is recommended that you use Puma's executable instead:
|
43
45
|
|
44
46
|
```
|
45
47
|
$ bundle exec puma
|
@@ -53,7 +55,7 @@ You can run your Sinatra application with Puma from the command line like this:
|
|
53
55
|
$ ruby app.rb -s Puma
|
54
56
|
```
|
55
57
|
|
56
|
-
Or you can configure your application to always use Puma:
|
58
|
+
Or you can configure your Sinatra application to always use Puma:
|
57
59
|
|
58
60
|
```ruby
|
59
61
|
require 'sinatra'
|
@@ -64,6 +66,9 @@ configure { set :server, :puma }
|
|
64
66
|
|
65
67
|
Puma provides numerous options. Consult `puma -h` (or `puma --help`) for a full list of CLI options, or see [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb).
|
66
68
|
|
69
|
+
You can also find several configuration examples as part of the
|
70
|
+
[test](test/config) suite.
|
71
|
+
|
67
72
|
### Thread Pool
|
68
73
|
|
69
74
|
Puma uses a thread pool. You can set the minimum and maximum number of threads that are available in the pool with the `-t` (or `--threads`) flag:
|
@@ -72,9 +77,9 @@ Puma uses a thread pool. You can set the minimum and maximum number of threads t
|
|
72
77
|
$ puma -t 8:32
|
73
78
|
```
|
74
79
|
|
75
|
-
Puma will automatically scale the number of threads, from the minimum until it caps out at the maximum, based on how much traffic is present. The current default is `0:16`. Feel free to experiment, but be careful not to set the number of maximum threads to a large number, as you may exhaust resources on the system (or
|
80
|
+
Puma will automatically scale the number of threads, from the minimum until it caps out at the maximum, based on how much traffic is present. The current default is `0:16`. Feel free to experiment, but be careful not to set the number of maximum threads to a large number, as you may exhaust resources on the system (or cause contention for the Global VM Lock, when using MRI).
|
76
81
|
|
77
|
-
Be aware that additionally Puma creates threads on its own for internal purposes (e.g. handling slow clients). So even if you specify -t 1:1, expect around 7 threads created in your application.
|
82
|
+
Be aware that additionally Puma creates threads on its own for internal purposes (e.g. handling slow clients). So, even if you specify -t 1:1, expect around 7 threads created in your application.
|
78
83
|
|
79
84
|
### Clustered mode
|
80
85
|
|
@@ -84,9 +89,9 @@ Puma also offers "clustered mode". Clustered mode `fork`s workers from a master
|
|
84
89
|
$ puma -t 8:32 -w 3
|
85
90
|
```
|
86
91
|
|
87
|
-
Note that threads are still used in clustered mode, and the `-t` thread flag setting is per worker, so `-w 2 -t 16:16` will spawn 32 threads in total.
|
92
|
+
Note that threads are still used in clustered mode, and the `-t` thread flag setting is per worker, so `-w 2 -t 16:16` will spawn 32 threads in total, with 16 in each worker process.
|
88
93
|
|
89
|
-
In clustered mode, Puma
|
94
|
+
In clustered mode, Puma can "preload" your application. This loads all the application code *prior* to forking. Preloading reduces total memory usage of your application via an operating system feature called [copy-on-write](https://en.wikipedia.org/wiki/Copy-on-write) (Ruby 2.0+ only). Use the `--preload` flag from the command line:
|
90
95
|
|
91
96
|
```
|
92
97
|
$ puma -w 3 --preload
|
@@ -111,40 +116,42 @@ end
|
|
111
116
|
|
112
117
|
This code can be used to setup the process before booting the application, allowing
|
113
118
|
you to do some Puma-specific things that you don't want to embed in your application.
|
114
|
-
For instance, you could fire a log notification that a worker booted or send something to statsd.
|
115
|
-
This can be called multiple times.
|
119
|
+
For instance, you could fire a log notification that a worker booted or send something to statsd. This can be called multiple times.
|
116
120
|
|
117
|
-
|
121
|
+
`before_fork` specifies a block to be run before workers are forked:
|
118
122
|
|
119
123
|
```ruby
|
120
124
|
# config/puma.rb
|
121
|
-
|
122
|
-
|
123
|
-
ActiveRecord::Base.establish_connection
|
124
|
-
end
|
125
|
+
before_fork do
|
126
|
+
# configuration here
|
125
127
|
end
|
126
128
|
```
|
127
129
|
|
128
|
-
|
130
|
+
Preloading can’t be used with phased restart, since phased restart kills and restarts workers one-by-one, and preload_app copies the code of master into the workers.
|
131
|
+
|
132
|
+
### Error handling
|
133
|
+
|
134
|
+
If puma encounters an error outside of the context of your application, it will respond with a 500 and a simple
|
135
|
+
textual error message (see `lowlevel_error` in [this file](https://github.com/puma/puma/blob/master/lib/puma/server.rb)).
|
136
|
+
You can specify custom behavior for this scenario. For example, you can report the error to your third-party
|
137
|
+
error-tracking service (in this example, [rollbar](http://rollbar.com)):
|
129
138
|
|
130
139
|
```ruby
|
131
|
-
|
132
|
-
|
133
|
-
|
140
|
+
lowlevel_error_handler do |e|
|
141
|
+
Rollbar.critical(e)
|
142
|
+
[500, {}, ["An error has occurred, and engineers have been informed. Please reload the page. If you continue to have problems, contact support@example.com\n"]]
|
134
143
|
end
|
135
144
|
```
|
136
145
|
|
137
|
-
Preloading can’t be used with phased restart, since phased restart kills and restarts workers one-by-one, and preload_app copies the code of master into the workers.
|
138
|
-
|
139
146
|
### Binding TCP / Sockets
|
140
147
|
|
141
|
-
|
148
|
+
Bind Puma to a socket with the `-b` (or `--bind`) flag:
|
142
149
|
|
143
150
|
```
|
144
151
|
$ puma -b tcp://127.0.0.1:9292
|
145
152
|
```
|
146
153
|
|
147
|
-
|
154
|
+
To use a UNIX Socket instead of TCP:
|
148
155
|
|
149
156
|
```
|
150
157
|
$ puma -b unix:///var/run/puma.sock
|
@@ -157,13 +164,14 @@ $ puma -b 'unix:///var/run/puma.sock?umask=0111'
|
|
157
164
|
```
|
158
165
|
|
159
166
|
Need a bit of security? Use SSL sockets:
|
167
|
+
|
160
168
|
```
|
161
169
|
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
|
162
170
|
```
|
163
171
|
|
164
172
|
#### Controlling SSL Cipher Suites
|
165
173
|
|
166
|
-
|
174
|
+
To use or avoid specific SSL cipher suites, use `ssl_cipher_filter` or `ssl_cipher_list` options.
|
167
175
|
|
168
176
|
##### Ruby:
|
169
177
|
|
@@ -179,7 +187,7 @@ $ puma -b 'ssl://127.0.0.1:9292?keystore=path_to_keystore&keystore-pass=keystore
|
|
179
187
|
|
180
188
|
See https://www.openssl.org/docs/man1.0.2/apps/ciphers.html for cipher filter format and full list of cipher suites.
|
181
189
|
|
182
|
-
|
190
|
+
Disable TLS v1 with the `no_tlsv1` option:
|
183
191
|
|
184
192
|
```
|
185
193
|
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&no_tlsv1=true'
|
@@ -187,13 +195,13 @@ $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&no_tlsv1=true'
|
|
187
195
|
|
188
196
|
### Control/Status Server
|
189
197
|
|
190
|
-
Puma has a built-in status
|
198
|
+
Puma has a built-in status and control app that can be used to query and control Puma.
|
191
199
|
|
192
200
|
```
|
193
201
|
$ puma --control-url tcp://127.0.0.1:9293 --control-token foo
|
194
202
|
```
|
195
203
|
|
196
|
-
Puma will start the control server on localhost port 9293. All requests to the control server will need to include `token=foo` as a query parameter. This allows for simple authentication. Check out [status.rb](https://github.com/puma/puma/blob/master/lib/puma/app/status.rb) to see what the app has available.
|
204
|
+
Puma will start the control server on localhost port 9293. All requests to the control server will need to include control token (in this case, `token=foo`) as a query parameter. This allows for simple authentication. Check out [status.rb](https://github.com/puma/puma/blob/master/lib/puma/app/status.rb) to see what the status app has available.
|
197
205
|
|
198
206
|
You can also interact with the control server via `pumactl`. This command will restart Puma:
|
199
207
|
|
@@ -205,13 +213,13 @@ To see a list of `pumactl` options, use `pumactl --help`.
|
|
205
213
|
|
206
214
|
### Configuration File
|
207
215
|
|
208
|
-
You can also provide a configuration file
|
216
|
+
You can also provide a configuration file with the `-C` (or `--config`) flag:
|
209
217
|
|
210
218
|
```
|
211
219
|
$ puma -C /path/to/config
|
212
220
|
```
|
213
221
|
|
214
|
-
If no configuration file is specified, Puma will look for a configuration file at `config/puma.rb`. If an environment is specified, either via the `-e` and `--environment` flags, or through the `RACK_ENV` environment variable,
|
222
|
+
If no configuration file is specified, Puma will look for a configuration file at `config/puma.rb`. If an environment is specified, either via the `-e` and `--environment` flags, or through the `RACK_ENV` environment variable, Puma looks for configuration at `config/puma/<environment_name>.rb`.
|
215
223
|
|
216
224
|
If you want to prevent Puma from looking for a configuration file in those locations, provide a dash as the argument to the `-C` (or `--config`) flag:
|
217
225
|
|
@@ -219,7 +227,7 @@ If you want to prevent Puma from looking for a configuration file in those locat
|
|
219
227
|
$ puma -C "-"
|
220
228
|
```
|
221
229
|
|
222
|
-
|
230
|
+
Check out [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb) to see all available options.
|
223
231
|
|
224
232
|
## Restart
|
225
233
|
|
@@ -236,7 +244,7 @@ Puma responds to several signals. A detailed guide to using UNIX signals with Pu
|
|
236
244
|
Some platforms do not support all Puma features.
|
237
245
|
|
238
246
|
* **JRuby**, **Windows**: server sockets are not seamless on restart, they must be closed and reopened. These platforms have no way to pass descriptors into a new process that is exposed to Ruby. Also, cluster mode is not supported due to a lack of fork(2).
|
239
|
-
* **Windows**:
|
247
|
+
* **Windows**: Cluster mode is not supported due to a lack of fork(2).
|
240
248
|
|
241
249
|
## Known Bugs
|
242
250
|
|
@@ -278,6 +286,26 @@ $ bundle install
|
|
278
286
|
$ bundle exec rake
|
279
287
|
```
|
280
288
|
|
289
|
+
To run a single test file, run only that file:
|
290
|
+
|
291
|
+
```bash
|
292
|
+
$ ruby -Ilib test/test_integration.rb
|
293
|
+
```
|
294
|
+
|
295
|
+
Or use [`m`](https://github.com/qrush/m):
|
296
|
+
|
297
|
+
```
|
298
|
+
$ bundle exec m test/test_binder.rb
|
299
|
+
```
|
300
|
+
|
301
|
+
Which can also be used to run a single test case:
|
302
|
+
|
303
|
+
```
|
304
|
+
$ bundle exec m test/test_binder.rb:37
|
305
|
+
```
|
306
|
+
|
307
|
+
If you open a pull request with a change that doesn't need to be noted in the changelog ([`History.md`](History.md)), add the text `[changelog skip]` to the pull request title to skip [the changelog check](https://github.com/puma/puma/pull/1991).
|
308
|
+
|
281
309
|
## License
|
282
310
|
|
283
311
|
Puma is copyright Evan Phoenix and contributors, licensed under the BSD 3-Clause license. See the included LICENSE file for details.
|
data/docs/plugins.md
CHANGED
@@ -1,15 +1,22 @@
|
|
1
1
|
## Plugins
|
2
2
|
|
3
|
-
Puma 3.0 added support for plugins that can augment configuration and service
|
3
|
+
Puma 3.0 added support for plugins that can augment configuration and service
|
4
|
+
operations.
|
4
5
|
|
5
6
|
2 canonical plugins to look to aid in development of further plugins:
|
6
7
|
|
7
|
-
* [tmp\_restart](https://github.com/puma/puma/blob/master/lib/puma/plugin/tmp_restart.rb):
|
8
|
-
|
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
|
9
12
|
|
10
|
-
Plugins are activated in a puma configuration file (such as `config/puma.rb'`)
|
13
|
+
Plugins are activated in a puma configuration file (such as `config/puma.rb'`)
|
14
|
+
by adding `plugin "name"`, such as `plugin "heroku"`.
|
11
15
|
|
12
|
-
Plugins are activated based simply on path requirements so, activating the
|
16
|
+
Plugins are activated based simply on path requirements so, activating the
|
17
|
+
`heroku` plugin will simply be doing `require "puma/plugin/heroku"`. This
|
18
|
+
allows gems to provide multiple plugins (as well as unrelated gems to provide
|
19
|
+
puma plugins).
|
13
20
|
|
14
21
|
The `tmp_restart` plugin is bundled with puma, so it can always be used.
|
15
22
|
|
@@ -17,12 +24,15 @@ To use the `heroku` plugin, add `puma-heroku` to your Gemfile or install it.
|
|
17
24
|
|
18
25
|
### API
|
19
26
|
|
20
|
-
|
27
|
+
## Server-wide hooks
|
21
28
|
|
22
|
-
|
29
|
+
Plugins can use a couple of hooks at server level: `start` and `config`.
|
23
30
|
|
24
|
-
`
|
31
|
+
`start` runs when the server has started and allows the plugin to start other
|
32
|
+
functionality to augment puma.
|
25
33
|
|
26
|
-
|
34
|
+
`config` runs when the server is being configured and is passed a `Puma::DSL`
|
35
|
+
object that can be used to add additional configuration.
|
27
36
|
|
28
|
-
|
37
|
+
Any public methods in `Puma::Plugin` are the public API that any plugin may
|
38
|
+
use.
|
@@ -38,7 +38,7 @@ static void snake_upcase_char(char *c)
|
|
38
38
|
|
39
39
|
#line 40 "ext/puma_http11/http11_parser.c"
|
40
40
|
static const int puma_parser_start = 1;
|
41
|
-
static const int puma_parser_first_final =
|
41
|
+
static const int puma_parser_first_final = 46;
|
42
42
|
static const int puma_parser_error = 0;
|
43
43
|
|
44
44
|
static const int puma_parser_en_main = 1;
|
@@ -117,17 +117,17 @@ case 2:
|
|
117
117
|
#line 118 "ext/puma_http11/http11_parser.c"
|
118
118
|
switch( (*p) ) {
|
119
119
|
case 32: goto tr2;
|
120
|
-
case 36: goto
|
121
|
-
case 95: goto
|
120
|
+
case 36: goto st27;
|
121
|
+
case 95: goto st27;
|
122
122
|
}
|
123
123
|
if ( (*p) < 48 ) {
|
124
124
|
if ( 45 <= (*p) && (*p) <= 46 )
|
125
|
-
goto
|
125
|
+
goto st27;
|
126
126
|
} else if ( (*p) > 57 ) {
|
127
127
|
if ( 65 <= (*p) && (*p) <= 90 )
|
128
|
-
goto
|
128
|
+
goto st27;
|
129
129
|
} else
|
130
|
-
goto
|
130
|
+
goto st27;
|
131
131
|
goto st0;
|
132
132
|
tr2:
|
133
133
|
#line 48 "ext/puma_http11/http11_parser.rl"
|
@@ -199,7 +199,7 @@ tr37:
|
|
199
199
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
200
200
|
}
|
201
201
|
goto st5;
|
202
|
-
|
202
|
+
tr41:
|
203
203
|
#line 58 "ext/puma_http11/http11_parser.rl"
|
204
204
|
{ MARK(query_start, p); }
|
205
205
|
#line 59 "ext/puma_http11/http11_parser.rl"
|
@@ -211,7 +211,7 @@ tr44:
|
|
211
211
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
212
212
|
}
|
213
213
|
goto st5;
|
214
|
-
|
214
|
+
tr44:
|
215
215
|
#line 59 "ext/puma_http11/http11_parser.rl"
|
216
216
|
{
|
217
217
|
parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
|
@@ -362,13 +362,13 @@ tr22:
|
|
362
362
|
{
|
363
363
|
parser->body_start = p - buffer + 1;
|
364
364
|
parser->header_done(parser, p + 1, pe - p - 1);
|
365
|
-
{p++; cs =
|
365
|
+
{p++; cs = 46; goto _out;}
|
366
366
|
}
|
367
|
-
goto
|
368
|
-
|
367
|
+
goto st46;
|
368
|
+
st46:
|
369
369
|
if ( ++p == pe )
|
370
|
-
goto
|
371
|
-
case
|
370
|
+
goto _test_eof46;
|
371
|
+
case 46:
|
372
372
|
#line 373 "ext/puma_http11/http11_parser.c"
|
373
373
|
goto st0;
|
374
374
|
tr21:
|
@@ -458,7 +458,7 @@ tr38:
|
|
458
458
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
459
459
|
}
|
460
460
|
goto st20;
|
461
|
-
|
461
|
+
tr42:
|
462
462
|
#line 58 "ext/puma_http11/http11_parser.rl"
|
463
463
|
{ MARK(query_start, p); }
|
464
464
|
#line 59 "ext/puma_http11/http11_parser.rl"
|
@@ -470,7 +470,7 @@ tr45:
|
|
470
470
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
471
471
|
}
|
472
472
|
goto st20;
|
473
|
-
|
473
|
+
tr45:
|
474
474
|
#line 59 "ext/puma_http11/http11_parser.rl"
|
475
475
|
{
|
476
476
|
parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
|
@@ -576,10 +576,9 @@ case 24:
|
|
576
576
|
case 32: goto tr37;
|
577
577
|
case 34: goto st0;
|
578
578
|
case 35: goto tr38;
|
579
|
-
case 59: goto tr39;
|
580
579
|
case 60: goto st0;
|
581
580
|
case 62: goto st0;
|
582
|
-
case 63: goto
|
581
|
+
case 63: goto tr39;
|
583
582
|
case 127: goto st0;
|
584
583
|
}
|
585
584
|
if ( 0 <= (*p) && (*p) <= 31 )
|
@@ -595,30 +594,27 @@ st25:
|
|
595
594
|
if ( ++p == pe )
|
596
595
|
goto _test_eof25;
|
597
596
|
case 25:
|
598
|
-
#line
|
597
|
+
#line 598 "ext/puma_http11/http11_parser.c"
|
599
598
|
switch( (*p) ) {
|
600
|
-
case 32: goto
|
599
|
+
case 32: goto tr41;
|
601
600
|
case 34: goto st0;
|
602
|
-
case 35: goto
|
601
|
+
case 35: goto tr42;
|
603
602
|
case 60: goto st0;
|
604
603
|
case 62: goto st0;
|
605
|
-
case 63: goto st26;
|
606
604
|
case 127: goto st0;
|
607
605
|
}
|
608
606
|
if ( 0 <= (*p) && (*p) <= 31 )
|
609
607
|
goto st0;
|
610
|
-
goto
|
608
|
+
goto tr40;
|
611
609
|
tr40:
|
612
|
-
#line
|
613
|
-
{
|
614
|
-
parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
|
615
|
-
}
|
610
|
+
#line 58 "ext/puma_http11/http11_parser.rl"
|
611
|
+
{ MARK(query_start, p); }
|
616
612
|
goto st26;
|
617
613
|
st26:
|
618
614
|
if ( ++p == pe )
|
619
615
|
goto _test_eof26;
|
620
616
|
case 26:
|
621
|
-
#line
|
617
|
+
#line 618 "ext/puma_http11/http11_parser.c"
|
622
618
|
switch( (*p) ) {
|
623
619
|
case 32: goto tr44;
|
624
620
|
case 34: goto st0;
|
@@ -629,27 +625,25 @@ case 26:
|
|
629
625
|
}
|
630
626
|
if ( 0 <= (*p) && (*p) <= 31 )
|
631
627
|
goto st0;
|
632
|
-
goto
|
633
|
-
tr43:
|
634
|
-
#line 58 "ext/puma_http11/http11_parser.rl"
|
635
|
-
{ MARK(query_start, p); }
|
636
|
-
goto st27;
|
628
|
+
goto st26;
|
637
629
|
st27:
|
638
630
|
if ( ++p == pe )
|
639
631
|
goto _test_eof27;
|
640
632
|
case 27:
|
641
|
-
#line 642 "ext/puma_http11/http11_parser.c"
|
642
633
|
switch( (*p) ) {
|
643
|
-
case 32: goto
|
644
|
-
case
|
645
|
-
case
|
646
|
-
case 60: goto st0;
|
647
|
-
case 62: goto st0;
|
648
|
-
case 127: goto st0;
|
634
|
+
case 32: goto tr2;
|
635
|
+
case 36: goto st28;
|
636
|
+
case 95: goto st28;
|
649
637
|
}
|
650
|
-
if (
|
651
|
-
|
652
|
-
|
638
|
+
if ( (*p) < 48 ) {
|
639
|
+
if ( 45 <= (*p) && (*p) <= 46 )
|
640
|
+
goto st28;
|
641
|
+
} else if ( (*p) > 57 ) {
|
642
|
+
if ( 65 <= (*p) && (*p) <= 90 )
|
643
|
+
goto st28;
|
644
|
+
} else
|
645
|
+
goto st28;
|
646
|
+
goto st0;
|
653
647
|
st28:
|
654
648
|
if ( ++p == pe )
|
655
649
|
goto _test_eof28;
|
@@ -960,24 +954,6 @@ st45:
|
|
960
954
|
if ( ++p == pe )
|
961
955
|
goto _test_eof45;
|
962
956
|
case 45:
|
963
|
-
switch( (*p) ) {
|
964
|
-
case 32: goto tr2;
|
965
|
-
case 36: goto st46;
|
966
|
-
case 95: goto st46;
|
967
|
-
}
|
968
|
-
if ( (*p) < 48 ) {
|
969
|
-
if ( 45 <= (*p) && (*p) <= 46 )
|
970
|
-
goto st46;
|
971
|
-
} else if ( (*p) > 57 ) {
|
972
|
-
if ( 65 <= (*p) && (*p) <= 90 )
|
973
|
-
goto st46;
|
974
|
-
} else
|
975
|
-
goto st46;
|
976
|
-
goto st0;
|
977
|
-
st46:
|
978
|
-
if ( ++p == pe )
|
979
|
-
goto _test_eof46;
|
980
|
-
case 46:
|
981
957
|
if ( (*p) == 32 )
|
982
958
|
goto tr2;
|
983
959
|
goto st0;
|
@@ -997,7 +973,7 @@ case 46:
|
|
997
973
|
_test_eof14: cs = 14; goto _test_eof;
|
998
974
|
_test_eof15: cs = 15; goto _test_eof;
|
999
975
|
_test_eof16: cs = 16; goto _test_eof;
|
1000
|
-
|
976
|
+
_test_eof46: cs = 46; goto _test_eof;
|
1001
977
|
_test_eof17: cs = 17; goto _test_eof;
|
1002
978
|
_test_eof18: cs = 18; goto _test_eof;
|
1003
979
|
_test_eof19: cs = 19; goto _test_eof;
|
@@ -1027,7 +1003,6 @@ case 46:
|
|
1027
1003
|
_test_eof43: cs = 43; goto _test_eof;
|
1028
1004
|
_test_eof44: cs = 44; goto _test_eof;
|
1029
1005
|
_test_eof45: cs = 45; goto _test_eof;
|
1030
|
-
_test_eof46: cs = 46; goto _test_eof;
|
1031
1006
|
|
1032
1007
|
_test_eof: {}
|
1033
1008
|
_out: {}
|