puma 3.12.0 → 5.0.0
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 +231 -0
- data/LICENSE +23 -20
- data/README.md +92 -51
- data/docs/architecture.md +4 -3
- data/docs/deployment.md +32 -6
- data/docs/fork_worker.md +31 -0
- data/docs/jungle/README.md +13 -0
- data/{tools → docs}/jungle/rc.d/README.md +0 -0
- data/{tools → docs}/jungle/rc.d/puma +0 -0
- data/{tools → docs}/jungle/rc.d/puma.conf +0 -0
- data/{tools → docs}/jungle/upstart/README.md +0 -0
- data/{tools → docs}/jungle/upstart/puma-manager.conf +0 -0
- data/{tools → docs}/jungle/upstart/puma.conf +0 -0
- data/docs/plugins.md +20 -10
- data/docs/restart.md +4 -2
- data/docs/signals.md +7 -6
- data/docs/systemd.md +22 -66
- data/ext/puma_http11/PumaHttp11Service.java +2 -2
- data/ext/puma_http11/extconf.rb +14 -0
- data/ext/puma_http11/http11_parser.c +40 -63
- data/ext/puma_http11/http11_parser.java.rl +21 -37
- data/ext/puma_http11/http11_parser.rl +3 -1
- data/ext/puma_http11/http11_parser_common.rl +3 -3
- data/ext/puma_http11/mini_ssl.c +101 -6
- data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
- data/ext/puma_http11/org/jruby/puma/Http11.java +108 -116
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +91 -106
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +92 -22
- data/ext/puma_http11/puma_http11.c +9 -38
- data/lib/puma.rb +25 -0
- data/lib/puma/accept_nonblock.rb +7 -1
- data/lib/puma/app/status.rb +50 -29
- data/lib/puma/binder.rb +120 -121
- data/lib/puma/cli.rb +13 -15
- data/lib/puma/client.rb +279 -201
- data/lib/puma/cluster.rb +240 -98
- data/lib/puma/commonlogger.rb +4 -2
- data/lib/puma/configuration.rb +37 -45
- data/lib/puma/const.rb +33 -19
- data/lib/puma/control_cli.rb +66 -27
- data/lib/puma/detect.rb +19 -0
- data/lib/puma/dsl.rb +425 -117
- data/lib/puma/error_logger.rb +97 -0
- data/lib/puma/events.rb +37 -28
- data/lib/puma/io_buffer.rb +9 -5
- data/lib/puma/jruby_restart.rb +2 -58
- data/lib/puma/launcher.rb +130 -68
- data/lib/puma/minissl.rb +95 -33
- data/lib/puma/minissl/context_builder.rb +73 -0
- data/lib/puma/null_io.rb +3 -1
- data/lib/puma/plugin.rb +8 -12
- data/lib/puma/plugin/tmp_restart.rb +2 -0
- data/lib/puma/rack/builder.rb +4 -5
- data/lib/puma/rack/urlmap.rb +2 -0
- data/lib/puma/rack_default.rb +2 -0
- data/lib/puma/reactor.rb +120 -60
- data/lib/puma/runner.rb +14 -32
- data/lib/puma/server.rb +209 -219
- data/lib/puma/single.rb +11 -66
- data/lib/puma/state_file.rb +8 -3
- data/lib/puma/thread_pool.rb +106 -77
- data/lib/puma/util.rb +2 -6
- data/lib/rack/handler/puma.rb +7 -6
- data/tools/Dockerfile +16 -0
- data/tools/trickletest.rb +0 -1
- metadata +38 -28
- data/ext/puma_http11/io_buffer.c +0 -155
- data/lib/puma/compat.rb +0 -14
- data/lib/puma/convenient.rb +0 -23
- data/lib/puma/daemon_ext.rb +0 -31
- data/lib/puma/delegation.rb +0 -11
- data/lib/puma/java_io_buffer.rb +0 -45
- data/lib/puma/rack/backports/uri/common_193.rb +0 -33
- data/lib/puma/tcp_logger.rb +0 -39
- data/tools/jungle/README.md +0 -19
- data/tools/jungle/init.d/README.md +0 -61
- data/tools/jungle/init.d/puma +0 -421
- data/tools/jungle/init.d/run-puma +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 124069677cb83205250fa0e90d7621739cb76da2f594dc661681f9d39e14227e
|
4
|
+
data.tar.gz: c58f64c5d4423ffb14d866bd820aaf4a3c0162f38ee75e638a831f226d9169ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ff75723d3e55450ba94897c1a0390f3040d74a28d56715ef6bda84af231a714c5739609db57fba443872d69c4bd7029ae0940726fd2b43fd328241cd1068680
|
7
|
+
data.tar.gz: ab2ff29b3181ab5ddea9975eadbdff33f582e7dbca26bd5eb4f429ae1ed31b0cdd10631f32bd4a9760a2a3b37fedef2fa91c3f33bf39fb944aa3041e7550d9b7
|
data/History.md
CHANGED
@@ -1,3 +1,225 @@
|
|
1
|
+
## 5.0.0
|
2
|
+
|
3
|
+
* Features
|
4
|
+
* Allow compiling without OpenSSL and dynamically load files needed for SSL, add 'no ssl' CI (#2305)
|
5
|
+
* EXPERIMENTAL: Add `fork_worker` option and `refork` command for reduced memory usage by forking from a worker process instead of the master process. (#2099)
|
6
|
+
* EXPERIMENTAL: Added `wait_for_less_busy_worker` config. This may reduce latency on MRI through inserting a small delay before re-listening on the socket if worker is busy (#2079).
|
7
|
+
* EXPERIMENTAL: Added `nakayoshi_fork` option. Reduce memory usage in preloaded cluster-mode apps by GCing before fork and compacting, where available. (#2093, #2256)
|
8
|
+
* Added pumactl `thread-backtraces` command to print thread backtraces (#2054)
|
9
|
+
* Added incrementing `requests_count` to `Puma.stats`. (#2106)
|
10
|
+
* Increased maximum URI path length from 2048 to 8192 bytes (#2167, #2344)
|
11
|
+
* `lowlevel_error_handler` is now called during a forced threadpool shutdown, and if a callable with 3 arguments is set, we now also pass the status code (#2203)
|
12
|
+
* Faster phased restart and worker timeout (#2220)
|
13
|
+
* Added `state_permission` to config DSL to set state file permissions (#2238)
|
14
|
+
* Added `Puma.stats_hash`, which returns a stats in Hash instead of a JSON string (#2086, #2253)
|
15
|
+
* `rack.multithread` and `rack.multiprocess` now dynamically resolved by `max_thread` and `workers` respectively (#2288)
|
16
|
+
|
17
|
+
* Deprecations, Removals and Breaking API Changes
|
18
|
+
* `--control` has been removed. Use `--control-url` (#1487)
|
19
|
+
* `worker_directory` has been removed. Use `directory`.
|
20
|
+
* min_threads now set by environment variables PUMA_MIN_THREADS and MIN_THREADS. (#2143)
|
21
|
+
* max_threads now set by environment variables PUMA_MAX_THREADS and MAX_THREADS. (#2143)
|
22
|
+
* max_threads default to 5 in MRI or 16 for all other interpreters. (#2143)
|
23
|
+
* preload by default if workers > 1 (#2143)
|
24
|
+
* Puma::Plugin.workers_supported? has been removed. Use Puma.forkable? instead. (#2143)
|
25
|
+
* `tcp_mode` has been removed without replacement. (#2169)
|
26
|
+
* Daemonization has been removed without replacement. (#2170)
|
27
|
+
* Changed #connected_port to #connected_ports (#2076)
|
28
|
+
* Configuration: `environment` is read from `RAILS_ENV`, if `RACK_ENV` can't be found (#2022)
|
29
|
+
* Log binding on http:// for TCP bindings to make it clickable
|
30
|
+
|
31
|
+
* Bugfixes
|
32
|
+
* Fix JSON loading issues on phased-restarts (#2269)
|
33
|
+
* Improve shutdown reliability (#2312, #2338)
|
34
|
+
* Close client http connections made to an ssl server with TLSv1.3 (#2116)
|
35
|
+
* Do not set user_config to quiet by default to allow for file config (#2074)
|
36
|
+
* Always close SSL connection in Puma::ControlCLI (#2211)
|
37
|
+
* Windows update extconf.rb for use with ssp and varied Ruby/MSYS2 combinations (#2069)
|
38
|
+
* Ensure control server Unix socket is closed on shutdown (#2112)
|
39
|
+
* Preserve `BUNDLE_GEMFILE` env var when using `prune_bundler` (#1893)
|
40
|
+
* Send 408 request timeout even when queue requests is disabled (#2119)
|
41
|
+
* Rescue IO::WaitReadable instead of EAGAIN for blocking read (#2121)
|
42
|
+
* Ensure `BUNDLE_GEMFILE` is unspecified in workers if unspecified in master when using `prune_bundler` (#2154)
|
43
|
+
* Rescue and log exceptions in hooks defined by users (on_worker_boot, after_worker_fork etc) (#1551)
|
44
|
+
* Read directly from the socket in #read_and_drop to avoid raising further SSL errors (#2198)
|
45
|
+
* Set `Connection: closed` header when queue requests is disabled (#2216)
|
46
|
+
* Pass queued requests to thread pool on server shutdown (#2122)
|
47
|
+
* Fixed a few minor concurrency bugs in ThreadPool that may have affected non-GVL Rubies (#2220)
|
48
|
+
* Fix `out_of_band` hook never executed if the number of worker threads is > 1 (#2177)
|
49
|
+
* Fix ThreadPool#shutdown timeout accuracy (#2221)
|
50
|
+
* Fix `UserFileDefaultOptions#fetch` to properly use `default` (#2233)
|
51
|
+
* Improvements to `out_of_band` hook (#2234)
|
52
|
+
* Prefer the rackup file specified by the CLI (#2225)
|
53
|
+
* Fix for spawning subprocesses with fork_worker option (#2267)
|
54
|
+
* Set `CONTENT_LENGTH` for chunked requests (#2287)
|
55
|
+
* JRuby - Add Puma::MiniSSL::Engine#init? and #teardown methods, run all SSL tests (#2317)
|
56
|
+
* Improve shutdown reliability (#2312)
|
57
|
+
* Resolve issue with threadpool waiting counter decrement when thread is killed
|
58
|
+
* Constrain rake-compiler version to 0.9.4 to fix `ClassNotFound` exception when using MiniSSL with Java8.
|
59
|
+
* Fix recursive `prune_bundler` (#2319).
|
60
|
+
* Ensure that TCP_CORK is usable
|
61
|
+
* Fix corner case when request body is chunked (#2326)
|
62
|
+
* Fix filehandle leak in MiniSSL (#2299)
|
63
|
+
|
64
|
+
* Refactor
|
65
|
+
* Remove unused loader argument from Plugin initializer (#2095)
|
66
|
+
* Simplify `Configuration.random_token` and remove insecure fallback (#2102)
|
67
|
+
* Simplify `Runner#start_control` URL parsing (#2111)
|
68
|
+
* Removed the IOBuffer extension and replaced with Ruby (#1980)
|
69
|
+
* Update `Rack::Handler::Puma.run` to use `**options` (#2189)
|
70
|
+
* ThreadPool concurrency refactoring (#2220)
|
71
|
+
* JSON parse cluster worker stats instead of regex (#2124)
|
72
|
+
* Support parallel tests in verbose progress reporting (#2223)
|
73
|
+
* Refactor error handling in server accept loop (#2239)
|
74
|
+
|
75
|
+
## 4.3.6 / 2020-09-05
|
76
|
+
|
77
|
+
* Bugfixes
|
78
|
+
* Explicitly include ctype.h to fix compilation warning and build error on macOS with Xcode 12 (#2304)
|
79
|
+
* Don't require json at boot (#2269)
|
80
|
+
|
81
|
+
## 4.3.4/4.3.5 and 3.12.5/3.12.6 / 2020-05-22
|
82
|
+
|
83
|
+
Each patchlevel release contains a separate security fix. We recommend simply upgrading to 4.3.5/3.12.6.
|
84
|
+
|
85
|
+
* Security
|
86
|
+
* Fix: Fixed two separate HTTP smuggling vulnerabilities that used the Transfer-Encoding header. CVE-2020-11076 and CVE-2020-11077.
|
87
|
+
|
88
|
+
## 4.3.3 and 3.12.4 / 2020-02-28
|
89
|
+
|
90
|
+
* Bugfixes
|
91
|
+
* Fix: Fixes a problem where we weren't splitting headers correctly on newlines (#2132)
|
92
|
+
* Security
|
93
|
+
* Fix: Prevent HTTP Response splitting via CR in early hints. CVE-2020-5249.
|
94
|
+
|
95
|
+
## 4.3.2 and 3.12.3 / 2020-02-27 (YANKED)
|
96
|
+
|
97
|
+
* Security
|
98
|
+
* Fix: Prevent HTTP Response splitting via CR/LF in header values. CVE-2020-5247.
|
99
|
+
|
100
|
+
## 4.3.1 and 3.12.2 / 2019-12-05
|
101
|
+
|
102
|
+
* Security
|
103
|
+
* Fix: a poorly-behaved client could use keepalive requests to monopolize Puma's reactor and create a denial of service attack. CVE-2019-16770.
|
104
|
+
|
105
|
+
## 4.3.0 / 2019-11-07
|
106
|
+
|
107
|
+
* Features
|
108
|
+
* Strip whitespace at end of HTTP headers (#2010)
|
109
|
+
* Optimize HTTP parser for JRuby (#2012)
|
110
|
+
* Add SSL support for the control app and cli (#2046, #2052)
|
111
|
+
|
112
|
+
* Bugfixes
|
113
|
+
* Fix Errno::EINVAL when SSL is enabled and browser rejects cert (#1564)
|
114
|
+
* Fix pumactl defaulting puma to development if an environment was not specified (#2035)
|
115
|
+
* Fix closing file stream when reading pid from pidfile (#2048)
|
116
|
+
* Fix a typo in configuration option `--extra_runtime_dependencies` (#2050)
|
117
|
+
|
118
|
+
## 4.2.1 / 2019-10-07
|
119
|
+
|
120
|
+
* 3 bugfixes
|
121
|
+
* Fix socket activation of systemd (pre-existing) unix binder files (#1842, #1988)
|
122
|
+
* Deal with multiple calls to bind correctly (#1986, #1994, #2006)
|
123
|
+
* Accepts symbols for `verify_mode` (#1222)
|
124
|
+
|
125
|
+
## 4.2.0 / 2019-09-23
|
126
|
+
|
127
|
+
* 6 features
|
128
|
+
* Pumactl has a new -e environment option and reads `config/puma/<environment>.rb` config files (#1885)
|
129
|
+
* Semicolons are now allowed in URL paths (MRI only), useful for Angular or Redmine (#1934)
|
130
|
+
* Allow extra dependencies to be defined when using prune_bundler (#1105)
|
131
|
+
* Puma now reports the correct port when binding to port 0, also reports other listeners when binding to localhost (#1786)
|
132
|
+
* Sending SIGINFO to any Puma worker now prints currently active threads and their backtraces (#1320)
|
133
|
+
* Puma threads all now have their name set on Ruby 2.3+ (#1968)
|
134
|
+
* 4 bugfixes
|
135
|
+
* Fix some misbehavior with phased restart and externally SIGTERMed workers (#1908, #1952)
|
136
|
+
* Fix socket closing on error (#1941)
|
137
|
+
* Removed unnecessary SIGINT trap for JRuby that caused some race conditions (#1961)
|
138
|
+
* Fix socket files being left around after process stopped (#1970)
|
139
|
+
* Absolutely thousands of lines of test improvements and fixes thanks to @MSP-Greg
|
140
|
+
|
141
|
+
## 4.1.1 / 2019-09-05
|
142
|
+
|
143
|
+
* 3 bugfixes
|
144
|
+
* Revert our attempt to not dup STDOUT/STDERR (#1946)
|
145
|
+
* Fix socket close on error (#1941)
|
146
|
+
* Fix workers not shutting down correctly (#1908)
|
147
|
+
|
148
|
+
## 4.1.0 / 2019-08-08
|
149
|
+
|
150
|
+
* 4 features
|
151
|
+
* Add REQUEST_PATH on parse error message (#1831)
|
152
|
+
* You can now easily add custom log formatters with the `log_formatter` config option (#1816)
|
153
|
+
* Puma.stats now provides process start times (#1844)
|
154
|
+
* Add support for disabling TLSv1.1 (#1836)
|
155
|
+
|
156
|
+
* 7 bugfixes
|
157
|
+
* Fix issue where Puma was creating zombie process entries (#1887)
|
158
|
+
* Fix bugs with line-endings and chunked encoding (#1812)
|
159
|
+
* RACK_URL_SCHEME is now set correctly in all conditions (#1491)
|
160
|
+
* We no longer mutate global STDOUT/STDERR, particularly the sync setting (#1837)
|
161
|
+
* SSL read_nonblock no longer blocks (#1857)
|
162
|
+
* Swallow connection errors when sending early hints (#1822)
|
163
|
+
* Backtrace no longer dumped when invalid pumactl commands are run (#1863)
|
164
|
+
|
165
|
+
* 5 other
|
166
|
+
* Avoid casting worker_timeout twice (#1838)
|
167
|
+
* Removed a call to private that wasn't doing anything (#1882)
|
168
|
+
* README, Rakefile, docs and test cleanups (#1848, #1847, #1846, #1853, #1859, #1850, #1866, #1870, #1872, #1833, #1888)
|
169
|
+
* Puma.io has proper documentation now (https://puma.io/puma/)
|
170
|
+
* Added the Contributor Covenant CoC
|
171
|
+
|
172
|
+
* 1 known issue
|
173
|
+
* Some users are still experiencing issues surrounding socket activation and Unix sockets (#1842)
|
174
|
+
|
175
|
+
## 4.0.1 / 2019-07-11
|
176
|
+
|
177
|
+
* 2 bugfixes
|
178
|
+
* Fix socket removed after reload - should fix problems with systemd socket activation. (#1829)
|
179
|
+
* 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)
|
180
|
+
* 1 other
|
181
|
+
* Removed unnecessary RUBY_VERSION checks. (#1827)
|
182
|
+
|
183
|
+
## 4.0.0 / 2019-06-25
|
184
|
+
|
185
|
+
* 9 features
|
186
|
+
* Add support for disabling TLSv1.0 (#1562)
|
187
|
+
* Request body read time metric (#1569)
|
188
|
+
* Add out_of_band hook (#1648)
|
189
|
+
* Re-implement (native) IOBuffer for JRuby (#1691)
|
190
|
+
* Min worker timeout (#1716)
|
191
|
+
* Add option to suppress SignalException on SIGTERM (#1690)
|
192
|
+
* Allow mutual TLS CA to be set using `ssl_bind` DSL (#1689)
|
193
|
+
* Reactor now uses nio4r instead of `select` (#1728)
|
194
|
+
* Add status to pumactl with pidfile (#1824)
|
195
|
+
|
196
|
+
* 10 bugfixes
|
197
|
+
* Do not accept new requests on shutdown (#1685, #1808)
|
198
|
+
* Fix 3 corner cases when request body is chunked (#1508)
|
199
|
+
* Change pid existence check's condition branches (#1650)
|
200
|
+
* Don't call .stop on a server that doesn't exist (#1655)
|
201
|
+
* Implemented NID_X9_62_prime256v1 (P-256) curve over P-521 (#1671)
|
202
|
+
* Fix @notify.close can't modify frozen IOError (RuntimeError) (#1583)
|
203
|
+
* Fix Java 8 support (#1773)
|
204
|
+
* Fix error `uninitialized constant Puma::Cluster` (#1731)
|
205
|
+
* Fix `not_token` being able to be set to true (#1803)
|
206
|
+
* Fix "Hang on SIGTERM with ruby 2.6 in clustered mode" ([PR #1741], [#1674], [#1720], [#1730], [#1755])
|
207
|
+
|
208
|
+
[PR #1741]: https://github.com/puma/puma/pull/1741
|
209
|
+
[#1674]: https://github.com/puma/puma/issues/1674
|
210
|
+
[#1720]: https://github.com/puma/puma/issues/1720
|
211
|
+
[#1730]: https://github.com/puma/puma/issues/1730
|
212
|
+
[#1755]: https://github.com/puma/puma/issues/1755
|
213
|
+
|
214
|
+
## 3.12.1 / 2019-03-19
|
215
|
+
|
216
|
+
* 1 features
|
217
|
+
* Internal strings are frozen (#1649)
|
218
|
+
* 3 bugfixes
|
219
|
+
* Fix chunked ending check (#1607)
|
220
|
+
* Rack handler should use provided default host (#1700)
|
221
|
+
* Better support for detecting runtimes that support `fork` (#1630)
|
222
|
+
|
1
223
|
## 3.12.0 / 2018-07-13
|
2
224
|
|
3
225
|
* 5 features:
|
@@ -1395,3 +1617,12 @@ be added back in a future date when a java Puma::MiniSSL is added.
|
|
1395
1617
|
## 1.0.0 / 2012-03-29
|
1396
1618
|
|
1397
1619
|
* Released!
|
1620
|
+
|
1621
|
+
## Ignore - this is for maintainers to copy-paste during release
|
1622
|
+
## Master
|
1623
|
+
|
1624
|
+
* Features
|
1625
|
+
* Your feature goes here (#Github Number)
|
1626
|
+
|
1627
|
+
* Bugfixes
|
1628
|
+
* Your bugfix goes here (#Github Number)
|
data/LICENSE
CHANGED
@@ -1,26 +1,29 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
BSD 3-Clause License
|
2
|
+
|
3
|
+
Copyright (c) 2019, Evan Phoenix. Some code by Zed Shaw, (c) 2005.
|
3
4
|
All rights reserved.
|
4
5
|
|
5
|
-
Redistribution and use in source and binary forms, with or without
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
6
7
|
modification, are permitted provided that the following conditions are met:
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
10
|
+
list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
17
|
+
contributors may be used to endorse or promote products derived from
|
18
|
+
this software without specific prior written permission.
|
16
19
|
|
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
|
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
|
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 HOLDER OR CONTRIBUTORS BE LIABLE
|
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
|
26
29
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -1,45 +1,55 @@
|
|
1
1
|
<p align="center">
|
2
|
-
<img src="
|
2
|
+
<img src="https://puma.io/images/logos/puma-logo-large.png">
|
3
3
|
</p>
|
4
4
|
|
5
5
|
# Puma: A Ruby Web Server Built For Concurrency
|
6
6
|
|
7
|
-
[![
|
8
|
-
[![Build Status](https://secure.travis-ci.org/puma/puma.svg)](http://travis-ci.org/puma/puma)
|
9
|
-
[![AppVeyor](https://img.shields.io/appveyor/ci/nateberkopec/puma.svg)](https://ci.appveyor.com/project/nateberkopec/puma)
|
10
|
-
[![Dependency Status](https://gemnasium.com/puma/puma.svg)](https://gemnasium.com/puma/puma)
|
7
|
+
[![Actions Build Status](https://github.com/puma/puma/workflows/CI/badge.svg?branch=master)](https://github.com/puma/puma/actions)
|
11
8
|
[![Code Climate](https://codeclimate.com/github/puma/puma.svg)](https://codeclimate.com/github/puma/puma)
|
9
|
+
[![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)
|
10
|
+
[![StackOverflow](https://img.shields.io/badge/stackoverflow-Puma-blue.svg)]( https://stackoverflow.com/questions/tagged/puma )
|
12
11
|
|
13
|
-
Puma is a **simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications
|
12
|
+
Puma is a **simple, fast, multi-threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications**.
|
14
13
|
|
15
14
|
## Built For Speed & Concurrency
|
16
15
|
|
17
|
-
|
16
|
+
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
17
|
|
19
|
-
Puma was designed to be the go-to server for [Rubinius](
|
18
|
+
Puma was designed to be the go-to server for [Rubinius](https://rubinius.com), but also works well with JRuby and MRI.
|
20
19
|
|
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
|
20
|
+
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
21
|
|
23
22
|
## Quick Start
|
24
23
|
|
25
24
|
```
|
26
25
|
$ gem install puma
|
27
|
-
$ puma
|
28
|
-
```
|
26
|
+
$ puma
|
27
|
+
```
|
28
|
+
|
29
|
+
Without arguments, puma will look for a rackup (.ru) file in
|
30
|
+
working directory called `config.ru`.
|
31
|
+
|
32
|
+
## SSL Connection Support
|
33
|
+
|
34
|
+
Puma will install/compile with support for ssl sockets, assuming OpenSSL
|
35
|
+
development files are installed on the system.
|
36
|
+
|
37
|
+
If the system does not have OpenSSL development files installed, Puma will
|
38
|
+
install/compile, but it will not allow ssl connections.
|
29
39
|
|
30
40
|
## Frameworks
|
31
41
|
|
32
42
|
### Rails
|
33
43
|
|
34
|
-
Puma is the default server for Rails,
|
44
|
+
Puma is the default server for Rails, included in the generated Gemfile.
|
35
45
|
|
36
|
-
|
46
|
+
Start your server with the `rails` command:
|
37
47
|
|
38
48
|
```
|
39
|
-
$ rails
|
49
|
+
$ rails server
|
40
50
|
```
|
41
51
|
|
42
|
-
Many configuration options are not available when using `rails
|
52
|
+
Many configuration options and Puma features are not available when using `rails server`. It is recommended that you use Puma's executable instead:
|
43
53
|
|
44
54
|
```
|
45
55
|
$ bundle exec puma
|
@@ -53,7 +63,7 @@ You can run your Sinatra application with Puma from the command line like this:
|
|
53
63
|
$ ruby app.rb -s Puma
|
54
64
|
```
|
55
65
|
|
56
|
-
Or you can configure your application to always use Puma:
|
66
|
+
Or you can configure your Sinatra application to always use Puma:
|
57
67
|
|
58
68
|
```ruby
|
59
69
|
require 'sinatra'
|
@@ -64,6 +74,9 @@ configure { set :server, :puma }
|
|
64
74
|
|
65
75
|
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
76
|
|
77
|
+
You can also find several configuration examples as part of the
|
78
|
+
[test](https://github.com/puma/puma/tree/master/test/config) suite.
|
79
|
+
|
67
80
|
### Thread Pool
|
68
81
|
|
69
82
|
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 +85,9 @@ Puma uses a thread pool. You can set the minimum and maximum number of threads t
|
|
72
85
|
$ puma -t 8:32
|
73
86
|
```
|
74
87
|
|
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
|
88
|
+
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` and on MRI is `0:5`. 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
89
|
|
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.
|
90
|
+
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
91
|
|
79
92
|
### Clustered mode
|
80
93
|
|
@@ -84,9 +97,9 @@ Puma also offers "clustered mode". Clustered mode `fork`s workers from a master
|
|
84
97
|
$ puma -t 8:32 -w 3
|
85
98
|
```
|
86
99
|
|
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.
|
100
|
+
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
101
|
|
89
|
-
In clustered mode, Puma
|
102
|
+
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
103
|
|
91
104
|
```
|
92
105
|
$ puma -w 3 --preload
|
@@ -111,40 +124,42 @@ end
|
|
111
124
|
|
112
125
|
This code can be used to setup the process before booting the application, allowing
|
113
126
|
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.
|
127
|
+
For instance, you could fire a log notification that a worker booted or send something to statsd. This can be called multiple times.
|
116
128
|
|
117
|
-
|
129
|
+
`before_fork` specifies a block to be run before workers are forked:
|
118
130
|
|
119
131
|
```ruby
|
120
132
|
# config/puma.rb
|
121
|
-
|
122
|
-
|
123
|
-
ActiveRecord::Base.establish_connection
|
124
|
-
end
|
133
|
+
before_fork do
|
134
|
+
# configuration here
|
125
135
|
end
|
126
136
|
```
|
127
137
|
|
128
|
-
|
138
|
+
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.
|
139
|
+
|
140
|
+
### Error handling
|
141
|
+
|
142
|
+
If puma encounters an error outside of the context of your application, it will respond with a 500 and a simple
|
143
|
+
textual error message (see `lowlevel_error` in [this file](https://github.com/puma/puma/blob/master/lib/puma/server.rb)).
|
144
|
+
You can specify custom behavior for this scenario. For example, you can report the error to your third-party
|
145
|
+
error-tracking service (in this example, [rollbar](https://rollbar.com)):
|
129
146
|
|
130
147
|
```ruby
|
131
|
-
|
132
|
-
|
133
|
-
|
148
|
+
lowlevel_error_handler do |e|
|
149
|
+
Rollbar.critical(e)
|
150
|
+
[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
151
|
end
|
135
152
|
```
|
136
153
|
|
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
154
|
### Binding TCP / Sockets
|
140
155
|
|
141
|
-
|
156
|
+
Bind Puma to a socket with the `-b` (or `--bind`) flag:
|
142
157
|
|
143
158
|
```
|
144
159
|
$ puma -b tcp://127.0.0.1:9292
|
145
160
|
```
|
146
161
|
|
147
|
-
|
162
|
+
To use a UNIX Socket instead of TCP:
|
148
163
|
|
149
164
|
```
|
150
165
|
$ puma -b unix:///var/run/puma.sock
|
@@ -157,30 +172,44 @@ $ puma -b 'unix:///var/run/puma.sock?umask=0111'
|
|
157
172
|
```
|
158
173
|
|
159
174
|
Need a bit of security? Use SSL sockets:
|
175
|
+
|
160
176
|
```
|
161
177
|
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
|
162
178
|
```
|
179
|
+
|
163
180
|
#### Controlling SSL Cipher Suites
|
164
|
-
|
165
|
-
|
181
|
+
|
182
|
+
To use or avoid specific SSL cipher suites, use `ssl_cipher_filter` or `ssl_cipher_list` options.
|
183
|
+
|
184
|
+
##### Ruby:
|
185
|
+
|
166
186
|
```
|
167
187
|
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&ssl_cipher_filter=!aNULL:AES+SHA'
|
168
188
|
```
|
169
|
-
|
189
|
+
|
190
|
+
##### JRuby:
|
191
|
+
|
170
192
|
```
|
171
193
|
$ 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'
|
172
194
|
```
|
195
|
+
|
173
196
|
See https://www.openssl.org/docs/man1.0.2/apps/ciphers.html for cipher filter format and full list of cipher suites.
|
174
197
|
|
198
|
+
Disable TLS v1 with the `no_tlsv1` option:
|
199
|
+
|
200
|
+
```
|
201
|
+
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&no_tlsv1=true'
|
202
|
+
```
|
203
|
+
|
175
204
|
### Control/Status Server
|
176
205
|
|
177
|
-
Puma has a built-in status
|
206
|
+
Puma has a built-in status and control app that can be used to query and control Puma.
|
178
207
|
|
179
208
|
```
|
180
209
|
$ puma --control-url tcp://127.0.0.1:9293 --control-token foo
|
181
210
|
```
|
182
211
|
|
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.
|
212
|
+
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.
|
184
213
|
|
185
214
|
You can also interact with the control server via `pumactl`. This command will restart Puma:
|
186
215
|
|
@@ -192,13 +221,13 @@ To see a list of `pumactl` options, use `pumactl --help`.
|
|
192
221
|
|
193
222
|
### Configuration File
|
194
223
|
|
195
|
-
You can also provide a configuration file
|
224
|
+
You can also provide a configuration file with the `-C` (or `--config`) flag:
|
196
225
|
|
197
226
|
```
|
198
227
|
$ puma -C /path/to/config
|
199
228
|
```
|
200
229
|
|
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
|
230
|
+
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` or the `RAILS_ENV` environment variables, Puma looks for configuration at `config/puma/<environment_name>.rb`.
|
202
231
|
|
203
232
|
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:
|
204
233
|
|
@@ -206,7 +235,9 @@ If you want to prevent Puma from looking for a configuration file in those locat
|
|
206
235
|
$ puma -C "-"
|
207
236
|
```
|
208
237
|
|
209
|
-
|
238
|
+
The other side-effects of setting the environment are whether to show stack traces (in `development` or `test`), and setting RACK_ENV may potentially affect middleware looking for this value to change their behavior. The default puma RACK_ENV value is `development`. You can see all config default values [here](https://github.com/puma/puma/blob/12d1706ddc71b89ed2ee26275e31c788e94ff541/lib/puma/configuration.rb#L170).
|
239
|
+
|
240
|
+
Check out [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb) to see all available options.
|
210
241
|
|
211
242
|
## Restart
|
212
243
|
|
@@ -223,11 +254,11 @@ Puma responds to several signals. A detailed guide to using UNIX signals with Pu
|
|
223
254
|
Some platforms do not support all Puma features.
|
224
255
|
|
225
256
|
* **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).
|
226
|
-
* **Windows**:
|
257
|
+
* **Windows**: Cluster mode is not supported due to a lack of fork(2).
|
227
258
|
|
228
259
|
## Known Bugs
|
229
260
|
|
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:
|
261
|
+
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:
|
231
262
|
|
232
263
|
```ruby
|
233
264
|
if %w(2.2.7 2.2.8 2.2.9 2.2.10 2.3.4 2.4.1).include? RUBY_VERSION
|
@@ -246,17 +277,27 @@ It is common to use process monitors with Puma. Modern process monitors like sys
|
|
246
277
|
provide continuous monitoring and restarts for increased
|
247
278
|
reliability in production environments:
|
248
279
|
|
249
|
-
* [
|
280
|
+
* [docs/jungle](https://github.com/puma/puma/tree/master/docs/jungle) for rc.d and upstart
|
250
281
|
* [docs/systemd](https://github.com/puma/puma/blob/master/docs/systemd.md)
|
251
282
|
|
283
|
+
## Community Extensions
|
284
|
+
|
285
|
+
### Plugins
|
286
|
+
|
287
|
+
* [puma-heroku](https://github.com/puma/puma-heroku) — default Puma configuration for running on Heroku
|
288
|
+
* [puma-metrics](https://github.com/harmjanblok/puma-metrics) — export Puma metrics to Prometheus
|
289
|
+
* [puma-plugin-statsd](https://github.com/yob/puma-plugin-statsd) — send Puma metrics to statsd
|
290
|
+
* [puma-plugin-systemd](https://github.com/sj26/puma-plugin-systemd) — deeper integration with systemd for notify, status and watchdog
|
291
|
+
|
292
|
+
### Monitoring
|
293
|
+
|
294
|
+
* [puma-status](https://github.com/ylecuyer/puma-status) — Monitor CPU/Mem/Load of running puma instances from the CLI
|
295
|
+
|
252
296
|
## Contributing
|
253
297
|
|
254
|
-
|
298
|
+
Find details for contributing in the [contribution guide].
|
255
299
|
|
256
|
-
|
257
|
-
$ bundle install
|
258
|
-
$ bundle exec rake
|
259
|
-
```
|
300
|
+
[contribution guide]: https://github.com/puma/puma/blob/master/CONTRIBUTING.md
|
260
301
|
|
261
302
|
## License
|
262
303
|
|