jun-puma 1.0.2-java → 1.0.3-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +451 -1870
- data/LICENSE +20 -23
- data/README.md +65 -226
- data/ext/puma_http11/extconf.rb +3 -64
- data/lib/puma/puma_http11.jar +0 -0
- metadata +9 -27
data/LICENSE
CHANGED
@@ -1,29 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Copyright (c) 2019, Evan Phoenix. Some code by Zed Shaw, (c) 2005.
|
1
|
+
Some code copyright (c) 2005, Zed Shaw
|
2
|
+
Copyright (c) 2011, Evan Phoenix
|
4
3
|
All rights reserved.
|
5
4
|
|
6
|
-
Redistribution and use in source and binary forms, with or without
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
7
6
|
modification, are permitted provided that the following conditions are met:
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
contributors may be used to endorse or promote products derived from
|
18
|
-
this software without specific prior written permission.
|
8
|
+
* Redistributions of source code must retain the above copyright notice, this
|
9
|
+
list of conditions and the following disclaimer.
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
* Neither the name of the Evan Phoenix nor the names of its contributors
|
14
|
+
may be used to endorse or promote products derived from this software
|
15
|
+
without specific prior written permission.
|
19
16
|
|
20
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
23
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
25
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
26
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
27
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
28
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
21
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
26
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -1,58 +1,45 @@
|
|
1
1
|
<p align="center">
|
2
|
-
<img src="
|
2
|
+
<img src="http://puma.io/images/logos/puma-logo-large.png">
|
3
3
|
</p>
|
4
4
|
|
5
|
-
# Puma: A Ruby Web Server Built For
|
5
|
+
# Puma: A Ruby Web Server Built For Concurrency
|
6
6
|
|
7
|
-
[](https://gitter.im/puma/puma?utm\_source=badge&utm\_medium=badge&utm\_campaign=pr-badge)
|
8
|
+
[](http://travis-ci.org/puma/puma)
|
9
|
+
[](https://ci.appveyor.com/project/nateberkopec/puma)
|
10
|
+
[](https://gemnasium.com/puma/puma)
|
8
11
|
[](https://codeclimate.com/github/puma/puma)
|
9
|
-
[]( https://stackoverflow.com/questions/tagged/puma )
|
10
12
|
|
11
|
-
Puma is a **simple, fast,
|
13
|
+
Puma is a **simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications** in development and production.
|
12
14
|
|
13
|
-
## Built For Speed &
|
15
|
+
## Built For Speed & Concurrency
|
14
16
|
|
15
|
-
Puma
|
16
|
-
* **Multi-threaded**. Each request is served in a separate thread. This helps you serve more requests per second with less memory use.
|
17
|
-
* **Multi-process**. "Pre-forks" in cluster mode, using less memory per-process thanks to copy-on-write memory.
|
18
|
-
* **Standalone**. With SSL support, zero-downtime rolling restarts and a built-in request bufferer, you can deploy Puma without any reverse proxy.
|
19
|
-
* **Battle-tested**. Our HTTP parser is inherited from Mongrel and has over 15 years of production use. Puma is currently the most popular Ruby webserver, and is the default server for Ruby on Rails.
|
17
|
+
Under the hood, 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 in a thread from an internal thread pool. Since each request is served in a separate thread, truly concurrent Ruby implementations (JRuby, Rubinius) will use all available CPU cores.
|
20
18
|
|
21
|
-
|
19
|
+
Puma was designed to be the go-to server for [Rubinius](http://rubini.us), but also works well with JRuby and MRI.
|
22
20
|
|
23
|
-
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
|
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 blocking IO to be run concurrently.
|
24
22
|
|
25
23
|
## Quick Start
|
26
24
|
|
27
25
|
```
|
28
26
|
$ gem install puma
|
29
|
-
$ puma
|
30
|
-
```
|
31
|
-
|
32
|
-
Without arguments, puma will look for a rackup (.ru) file in
|
33
|
-
working directory called `config.ru`.
|
34
|
-
|
35
|
-
## SSL Connection Support
|
36
|
-
|
37
|
-
Puma will install/compile with support for ssl sockets, assuming OpenSSL
|
38
|
-
development files are installed on the system.
|
39
|
-
|
40
|
-
If the system does not have OpenSSL development files installed, Puma will
|
41
|
-
install/compile, but it will not allow ssl connections.
|
27
|
+
$ puma <any rackup (*.ru) file>
|
28
|
+
```
|
42
29
|
|
43
30
|
## Frameworks
|
44
31
|
|
45
32
|
### Rails
|
46
33
|
|
47
|
-
Puma is the default server for Rails, included in
|
34
|
+
Puma is the default server for Rails, and should already be included in your Gemfile.
|
48
35
|
|
49
|
-
|
36
|
+
Then start your server with the `rails` command:
|
50
37
|
|
51
38
|
```
|
52
|
-
$ rails
|
39
|
+
$ rails s
|
53
40
|
```
|
54
41
|
|
55
|
-
Many configuration options
|
42
|
+
Many configuration options are not available when using `rails s`. It is recommended that you use Puma's executable instead:
|
56
43
|
|
57
44
|
```
|
58
45
|
$ bundle exec puma
|
@@ -66,29 +53,16 @@ You can run your Sinatra application with Puma from the command line like this:
|
|
66
53
|
$ ruby app.rb -s Puma
|
67
54
|
```
|
68
55
|
|
69
|
-
|
56
|
+
Or you can configure your application to always use Puma:
|
70
57
|
|
71
58
|
```ruby
|
72
|
-
|
73
|
-
|
74
|
-
run Sinatra::Application
|
75
|
-
```
|
76
|
-
|
77
|
-
You can then start your application using:
|
78
|
-
|
79
|
-
```
|
80
|
-
$ bundle exec puma
|
59
|
+
require 'sinatra'
|
60
|
+
configure { set :server, :puma }
|
81
61
|
```
|
82
62
|
|
83
63
|
## Configuration
|
84
64
|
|
85
|
-
Puma provides numerous options. Consult `puma -h` (or `puma --help`) for a full list of CLI options, or see
|
86
|
-
|
87
|
-
You can also find several configuration examples as part of the
|
88
|
-
[test](https://github.com/puma/puma/tree/master/test/config) suite.
|
89
|
-
|
90
|
-
For debugging purposes, you can set the environment variable `PUMA_LOG_CONFIG` with a value
|
91
|
-
and the loaded configuration will be printed as part of the boot process.
|
65
|
+
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).
|
92
66
|
|
93
67
|
### Thread Pool
|
94
68
|
|
@@ -98,9 +72,9 @@ Puma uses a thread pool. You can set the minimum and maximum number of threads t
|
|
98
72
|
$ puma -t 8:32
|
99
73
|
```
|
100
74
|
|
101
|
-
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
|
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 hit resource limits).
|
102
76
|
|
103
|
-
Be aware that additionally Puma creates threads on its own for internal purposes (e.g. handling slow clients). So
|
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.
|
104
78
|
|
105
79
|
### Clustered mode
|
106
80
|
|
@@ -110,25 +84,15 @@ Puma also offers "clustered mode". Clustered mode `fork`s workers from a master
|
|
110
84
|
$ puma -t 8:32 -w 3
|
111
85
|
```
|
112
86
|
|
113
|
-
|
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.
|
114
88
|
|
115
|
-
|
116
|
-
$ WEB_CONCURRENCY=3 puma -t 8:32
|
117
|
-
```
|
118
|
-
|
119
|
-
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.
|
120
|
-
|
121
|
-
For an in-depth discussion of the tradeoffs of thread and process count settings, [see our docs](https://github.com/puma/puma/blob/9282a8efa5a0c48e39c60d22ca70051a25df9f55/docs/kubernetes.md#workers-per-pod-and-other-config-issues).
|
122
|
-
|
123
|
-
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).
|
124
|
-
|
125
|
-
If the `WEB_CONCURRENCY` environment variable is set to a value > 1 (and `--prune-bundler` has not been specified), preloading will be enabled by default. Otherwise, you can use the `--preload` flag from the command line:
|
89
|
+
In clustered mode, Puma may "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:
|
126
90
|
|
127
91
|
```
|
128
92
|
$ puma -w 3 --preload
|
129
93
|
```
|
130
94
|
|
131
|
-
|
95
|
+
If you're using a configuration file, use the `preload_app!` method:
|
132
96
|
|
133
97
|
```ruby
|
134
98
|
# config/puma.rb
|
@@ -136,9 +100,7 @@ workers 3
|
|
136
100
|
preload_app!
|
137
101
|
```
|
138
102
|
|
139
|
-
|
140
|
-
|
141
|
-
When using clustered mode, you can specify a block in your configuration file that will be run on boot of each worker:
|
103
|
+
Additionally, you can specify a block in your configuration file that will be run on boot of each worker:
|
142
104
|
|
143
105
|
```ruby
|
144
106
|
# config/puma.rb
|
@@ -149,52 +111,40 @@ end
|
|
149
111
|
|
150
112
|
This code can be used to setup the process before booting the application, allowing
|
151
113
|
you to do some Puma-specific things that you don't want to embed in your application.
|
152
|
-
For instance, you could fire a log notification that a worker booted or send something to statsd.
|
153
|
-
|
154
|
-
Constants loaded by your application (such as `Rails`) will not be available in `on_worker_boot`
|
155
|
-
unless preloading is enabled.
|
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.
|
156
116
|
|
157
|
-
|
117
|
+
If you're preloading your application and using ActiveRecord, it's recommended that you setup your connection pool here:
|
158
118
|
|
159
119
|
```ruby
|
160
120
|
# config/puma.rb
|
161
|
-
|
162
|
-
|
121
|
+
on_worker_boot do
|
122
|
+
ActiveSupport.on_load(:active_record) do
|
123
|
+
ActiveRecord::Base.establish_connection
|
124
|
+
end
|
163
125
|
end
|
164
126
|
```
|
165
127
|
|
166
|
-
|
128
|
+
On top of that, you can specify a block in your configuration file that will be run before workers are forked:
|
167
129
|
|
168
130
|
```ruby
|
169
131
|
# config/puma.rb
|
170
|
-
|
132
|
+
before_fork do
|
171
133
|
# configuration here
|
172
134
|
end
|
173
135
|
```
|
174
136
|
|
175
|
-
|
176
|
-
|
177
|
-
If puma encounters an error outside of the context of your application, it will respond with a 500 and a simple
|
178
|
-
textual error message (see `Puma::Server#lowlevel_error` or [server.rb](https://github.com/puma/puma/blob/master/lib/puma/server.rb)).
|
179
|
-
You can specify custom behavior for this scenario. For example, you can report the error to your third-party
|
180
|
-
error-tracking service (in this example, [rollbar](https://rollbar.com)):
|
181
|
-
|
182
|
-
```ruby
|
183
|
-
lowlevel_error_handler do |e|
|
184
|
-
Rollbar.critical(e)
|
185
|
-
[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"]]
|
186
|
-
end
|
187
|
-
```
|
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.
|
188
138
|
|
189
139
|
### Binding TCP / Sockets
|
190
140
|
|
191
|
-
|
141
|
+
In contrast to many other server configs which require multiple flags, Puma simply uses one URI parameter with the `-b` (or `--bind`) flag:
|
192
142
|
|
193
143
|
```
|
194
144
|
$ puma -b tcp://127.0.0.1:9292
|
195
145
|
```
|
196
146
|
|
197
|
-
|
147
|
+
Want to use UNIX Sockets instead of TCP (which can provide a 5-10% performance boost)?
|
198
148
|
|
199
149
|
```
|
200
150
|
$ puma -b unix:///var/run/puma.sock
|
@@ -207,120 +157,30 @@ $ puma -b 'unix:///var/run/puma.sock?umask=0111'
|
|
207
157
|
```
|
208
158
|
|
209
159
|
Need a bit of security? Use SSL sockets:
|
210
|
-
|
211
160
|
```
|
212
161
|
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
|
213
162
|
```
|
214
|
-
#### Self-signed SSL certificates (via the [`localhost`] gem, for development use):
|
215
|
-
|
216
|
-
Puma supports the [`localhost`] gem for self-signed certificates. This is particularly useful if you want to use Puma with SSL locally, and self-signed certificates will work for your use-case. Currently, the integration can only be used in MRI.
|
217
|
-
|
218
|
-
Puma automatically configures SSL when the [`localhost`] gem is loaded in a `development` environment:
|
219
|
-
|
220
|
-
Add the gem to your Gemfile:
|
221
|
-
```ruby
|
222
|
-
group(:development) do
|
223
|
-
gem 'localhost'
|
224
|
-
end
|
225
|
-
```
|
226
|
-
|
227
|
-
And require it implicitly using bundler:
|
228
|
-
```ruby
|
229
|
-
require "bundler"
|
230
|
-
Bundler.require(:default, ENV["RACK_ENV"].to_sym)
|
231
|
-
```
|
232
|
-
|
233
|
-
Alternatively, you can require the gem in your configuration file, either `config/puma/development.rb`, `config/puma.rb`, or set via the `-C` cli option:
|
234
|
-
```ruby
|
235
|
-
require 'localhost'
|
236
|
-
# configuration methods (from Puma::DSL) as needed
|
237
|
-
```
|
238
|
-
|
239
|
-
Additionally, Puma must be listening to an SSL socket:
|
240
|
-
|
241
|
-
```shell
|
242
|
-
$ puma -b 'ssl://localhost:9292' -C config/use_local_host.rb
|
243
|
-
|
244
|
-
# The following options allow you to reach Puma over HTTP as well:
|
245
|
-
$ puma -b ssl://localhost:9292 -b tcp://localhost:9393 -C config/use_local_host.rb
|
246
|
-
```
|
247
|
-
|
248
|
-
[`localhost`]: https://github.com/socketry/localhost
|
249
|
-
|
250
163
|
#### Controlling SSL Cipher Suites
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
##### Ruby:
|
255
|
-
|
164
|
+
Need to use or avoid specific SSL cipher suites? Use ssl_cipher_filter or ssl_cipher_list options.
|
165
|
+
#####Ruby:
|
256
166
|
```
|
257
167
|
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&ssl_cipher_filter=!aNULL:AES+SHA'
|
258
168
|
```
|
259
|
-
|
260
|
-
##### JRuby:
|
261
|
-
|
169
|
+
#####JRuby:
|
262
170
|
```
|
263
171
|
$ puma -b 'ssl://127.0.0.1:9292?keystore=path_to_keystore&keystore-pass=keystore_password&ssl_cipher_list=TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA'
|
264
172
|
```
|
265
|
-
|
266
|
-
See https://www.openssl.org/docs/man1.1.1/man1/ciphers.html for cipher filter format and full list of cipher suites.
|
267
|
-
|
268
|
-
Disable TLS v1 with the `no_tlsv1` option:
|
269
|
-
|
270
|
-
```
|
271
|
-
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&no_tlsv1=true'
|
272
|
-
```
|
273
|
-
|
274
|
-
#### Controlling OpenSSL Verification Flags
|
275
|
-
|
276
|
-
To enable verification flags offered by OpenSSL, use `verification_flags` (not available for JRuby):
|
277
|
-
|
278
|
-
```
|
279
|
-
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&verification_flags=PARTIAL_CHAIN'
|
280
|
-
```
|
281
|
-
|
282
|
-
You can also set multiple verification flags (by separating them with coma):
|
283
|
-
|
284
|
-
```
|
285
|
-
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&verification_flags=PARTIAL_CHAIN,CRL_CHECK'
|
286
|
-
```
|
287
|
-
|
288
|
-
List of available flags: `USE_CHECK_TIME`, `CRL_CHECK`, `CRL_CHECK_ALL`, `IGNORE_CRITICAL`, `X509_STRICT`, `ALLOW_PROXY_CERTS`, `POLICY_CHECK`, `EXPLICIT_POLICY`, `INHIBIT_ANY`, `INHIBIT_MAP`, `NOTIFY_POLICY`, `EXTENDED_CRL_SUPPORT`, `USE_DELTAS`, `CHECK_SS_SIGNATURE`, `TRUSTED_FIRST`, `SUITEB_128_LOS_ONLY`, `SUITEB_192_LOS`, `SUITEB_128_LOS`, `PARTIAL_CHAIN`, `NO_ALT_CHAINS`, `NO_CHECK_TIME`
|
289
|
-
(see https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_hostflags.html#VERIFICATION-FLAGS).
|
290
|
-
|
291
|
-
#### Controlling OpenSSL Password Decryption
|
292
|
-
|
293
|
-
To enable runtime decryption of an encrypted SSL key (not available for JRuby), use `key_password_command`:
|
294
|
-
|
295
|
-
```
|
296
|
-
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&key_password_command=/path/to/command.sh'
|
297
|
-
```
|
298
|
-
|
299
|
-
`key_password_command` must:
|
300
|
-
|
301
|
-
1. Be executable by Puma.
|
302
|
-
2. Print the decryption password to stdout.
|
303
|
-
|
304
|
-
For example:
|
305
|
-
|
306
|
-
```shell
|
307
|
-
#!/bin/sh
|
308
|
-
|
309
|
-
echo "this is my password"
|
310
|
-
```
|
311
|
-
|
312
|
-
`key_password_command` can be used with `key` or `key_pem`. If the key
|
313
|
-
is not encrypted, the executable will not be called.
|
173
|
+
See https://www.openssl.org/docs/man1.0.2/apps/ciphers.html for cipher filter format and full list of cipher suites.
|
314
174
|
|
315
175
|
### Control/Status Server
|
316
176
|
|
317
|
-
Puma has a built-in status
|
177
|
+
Puma has a built-in status/control app that can be used to query and control Puma itself.
|
318
178
|
|
319
179
|
```
|
320
180
|
$ puma --control-url tcp://127.0.0.1:9293 --control-token foo
|
321
181
|
```
|
322
182
|
|
323
|
-
Puma will start the control server on localhost port 9293. All requests to the control server will need to include
|
183
|
+
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.
|
324
184
|
|
325
185
|
You can also interact with the control server via `pumactl`. This command will restart Puma:
|
326
186
|
|
@@ -332,49 +192,42 @@ To see a list of `pumactl` options, use `pumactl --help`.
|
|
332
192
|
|
333
193
|
### Configuration File
|
334
194
|
|
335
|
-
You can also provide a configuration file with the `-C` (or `--config`) flag:
|
195
|
+
You can also provide a configuration file which Puma will use with the `-C` (or `--config`) flag:
|
336
196
|
|
337
197
|
```
|
338
198
|
$ puma -C /path/to/config
|
339
199
|
```
|
340
200
|
|
341
|
-
If no configuration file is specified, Puma will look for a configuration file at `config/puma.rb`. If an environment is specified
|
201
|
+
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, the default file location will be `config/puma/environment_name.rb`.
|
342
202
|
|
343
|
-
If you want to prevent Puma from looking for a configuration file in those locations,
|
203
|
+
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:
|
344
204
|
|
345
205
|
```
|
346
|
-
$ puma --no-config
|
347
|
-
|
348
|
-
# or
|
349
|
-
|
350
206
|
$ puma -C "-"
|
351
207
|
```
|
352
208
|
|
353
|
-
|
354
|
-
|
355
|
-
Check out `Puma::DSL` or [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb) to see all available options.
|
209
|
+
Take the following [sample configuration](https://github.com/puma/puma/blob/master/examples/config.rb) as inspiration or check out [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb) to see all available options.
|
356
210
|
|
357
211
|
## Restart
|
358
212
|
|
359
213
|
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.
|
360
214
|
|
361
|
-
For more, see the [
|
215
|
+
For more, see the [restart documentation](https://github.com/puma/puma/blob/master/docs/restart.md).
|
362
216
|
|
363
217
|
## Signals
|
364
218
|
|
365
|
-
Puma responds to several signals. A detailed guide to using UNIX signals with Puma can be found in the [
|
219
|
+
Puma responds to several signals. A detailed guide to using UNIX signals with Puma can be found in the [signals documentation](https://github.com/puma/puma/blob/master/docs/signals.md).
|
366
220
|
|
367
221
|
## Platform Constraints
|
368
222
|
|
369
223
|
Some platforms do not support all Puma features.
|
370
224
|
|
371
225
|
* **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).
|
372
|
-
* **Windows**:
|
373
|
-
* **Kubernetes**: The way Kubernetes handles pod shutdowns interacts poorly with server processes implementing graceful shutdown, like Puma. See the [kubernetes section of the documentation](docs/kubernetes.md) for more details.
|
226
|
+
* **Windows**: daemon mode is not supported due to a lack of fork(2).
|
374
227
|
|
375
228
|
## Known Bugs
|
376
229
|
|
377
|
-
For MRI versions 2.2.7, 2.2.8, 2.2.9, 2.2.10
|
230
|
+
For MRI versions 2.2.7, 2.2.8, 2.2.9, 2.2.10 2.3.4 and 2.4.1, you may see ```stream closed in another thread (IOError)```. It may be caused by a [Ruby bug](https://bugs.ruby-lang.org/issues/13632). It can be fixed with the gem https://rubygems.org/gems/stopgap_13632:
|
378
231
|
|
379
232
|
```ruby
|
380
233
|
if %w(2.2.7 2.2.8 2.2.9 2.2.10 2.3.4 2.4.1).include? RUBY_VERSION
|
@@ -387,37 +240,23 @@ end
|
|
387
240
|
|
388
241
|
## Deployment
|
389
242
|
|
390
|
-
|
243
|
+
Puma has support for Capistrano with an [external gem](https://github.com/seuros/capistrano-puma).
|
391
244
|
|
392
|
-
|
245
|
+
It is common to use process monitors with Puma. Modern process monitors like systemd or upstart
|
246
|
+
provide continuous monitoring and restarts for increased
|
247
|
+
reliability in production environments:
|
393
248
|
|
394
|
-
|
395
|
-
|
396
|
-
provide continuous monitoring and restarts for increased reliability in production environments:
|
397
|
-
|
398
|
-
* [rc.d](docs/jungle/rc.d/README.md)
|
399
|
-
* [systemd](docs/systemd.md)
|
400
|
-
|
401
|
-
Community guides:
|
402
|
-
|
403
|
-
* [Deploying Puma on OpenBSD using relayd and httpd](https://gist.github.com/anon987654321/4532cf8d6c59c1f43ec8973faa031103)
|
404
|
-
|
405
|
-
## Community Extensions
|
406
|
-
|
407
|
-
### Plugins
|
408
|
-
|
409
|
-
* [puma-metrics](https://github.com/harmjanblok/puma-metrics) — export Puma metrics to Prometheus
|
410
|
-
* [puma-plugin-statsd](https://github.com/yob/puma-plugin-statsd) — send Puma metrics to statsd
|
411
|
-
* [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.
|
412
|
-
* [puma-plugin-telemetry](https://github.com/babbel/puma-plugin-telemetry) - telemetry plugin for Puma offering various targets to publish
|
413
|
-
|
414
|
-
### Monitoring
|
415
|
-
|
416
|
-
* [puma-status](https://github.com/ylecuyer/puma-status) — Monitor CPU/Mem/Load of running puma instances from the CLI
|
249
|
+
* [tools/jungle](https://github.com/puma/puma/tree/master/tools/jungle) for sysvinit (init.d) and upstart
|
250
|
+
* [docs/systemd](https://github.com/puma/puma/blob/master/docs/systemd.md)
|
417
251
|
|
418
252
|
## Contributing
|
419
253
|
|
420
|
-
|
254
|
+
To run the test suite:
|
255
|
+
|
256
|
+
```bash
|
257
|
+
$ bundle install
|
258
|
+
$ bundle exec rake
|
259
|
+
```
|
421
260
|
|
422
261
|
## License
|
423
262
|
|
data/ext/puma_http11/extconf.rb
CHANGED
@@ -2,74 +2,13 @@ require 'mkmf'
|
|
2
2
|
|
3
3
|
dir_config("puma_http11")
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
append_ldflags '-fstack-protector-strong -l:libssp.a'
|
8
|
-
have_library 'ssp'
|
9
|
-
end
|
10
|
-
|
11
|
-
unless ENV["PUMA_DISABLE_SSL"]
|
12
|
-
# don't use pkg_config('openssl') if '--with-openssl-dir' is used
|
13
|
-
has_openssl_dir = dir_config('openssl').any?
|
14
|
-
# macOS TruffleRuby problem
|
15
|
-
found_pkg_config = RUBY_ENGINE == 'truffleruby' &&
|
16
|
-
RUBY_PLATFORM.include?('darwin') && ENV['GITHUB_ACTIONS'] == 'true' ?
|
17
|
-
false : !has_openssl_dir && pkg_config('openssl')
|
5
|
+
unless ENV["DISABLE_SSL"]
|
6
|
+
dir_config("openssl")
|
18
7
|
|
19
|
-
|
20
|
-
puts 'using OpenSSL pkgconfig (openssl.pc)'
|
21
|
-
true
|
22
|
-
elsif have_library('libcrypto', 'BIO_read') && have_library('libssl', 'SSL_CTX_new')
|
23
|
-
true
|
24
|
-
elsif %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} &&
|
8
|
+
if %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} and
|
25
9
|
%w'ssl ssleay32'.find {|ssl| have_library(ssl, 'SSL_CTX_new')}
|
26
|
-
true
|
27
|
-
else
|
28
|
-
puts '** Puma will be compiled without SSL support'
|
29
|
-
false
|
30
|
-
end
|
31
10
|
|
32
|
-
if found_ssl
|
33
11
|
have_header "openssl/bio.h"
|
34
|
-
|
35
|
-
# below is yes for 1.0.2 & later
|
36
|
-
have_func "DTLS_method" , "openssl/ssl.h"
|
37
|
-
have_func "SSL_CTX_set_session_cache_mode(NULL, 0)", "openssl/ssl.h"
|
38
|
-
|
39
|
-
# below are yes for 1.1.0 & later
|
40
|
-
have_func "TLS_server_method" , "openssl/ssl.h"
|
41
|
-
have_func "SSL_CTX_set_min_proto_version(NULL, 0)" , "openssl/ssl.h"
|
42
|
-
|
43
|
-
have_func "X509_STORE_up_ref"
|
44
|
-
have_func "SSL_CTX_set_ecdh_auto(NULL, 0)" , "openssl/ssl.h"
|
45
|
-
|
46
|
-
# below exists in 1.1.0 and later, but isn't documented until 3.0.0
|
47
|
-
have_func "SSL_CTX_set_dh_auto(NULL, 0)" , "openssl/ssl.h"
|
48
|
-
|
49
|
-
# below is yes for 3.0.0 & later
|
50
|
-
have_func "SSL_get1_peer_certificate" , "openssl/ssl.h"
|
51
|
-
|
52
|
-
# Random.bytes available in Ruby 2.5 and later, Random::DEFAULT deprecated in 3.0
|
53
|
-
if Random.respond_to?(:bytes)
|
54
|
-
$defs.push "-DHAVE_RANDOM_BYTES"
|
55
|
-
puts "checking for Random.bytes... yes"
|
56
|
-
else
|
57
|
-
puts "checking for Random.bytes... no"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
if ENV["PUMA_MAKE_WARNINGS_INTO_ERRORS"]
|
63
|
-
# Make all warnings into errors
|
64
|
-
# Except `implicit-fallthrough` since most failures comes from ragel state machine generated code
|
65
|
-
if respond_to?(:append_cflags, true) # Ruby 2.5 and later
|
66
|
-
append_cflags(config_string('WERRORFLAG') || '-Werror')
|
67
|
-
append_cflags '-Wno-implicit-fallthrough'
|
68
|
-
else
|
69
|
-
# flag may not exist on some platforms, -Werror may not be defined on some platforms, but
|
70
|
-
# works with all in current CI
|
71
|
-
$CFLAGS << " #{config_string('WERRORFLAG') || '-Werror'}"
|
72
|
-
$CFLAGS << ' -Wno-implicit-fallthrough'
|
73
12
|
end
|
74
13
|
end
|
75
14
|
|
data/lib/puma/puma_http11.jar
CHANGED
Binary file
|