puma 3.9.1 → 3.10.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 +29 -0
- data/README.md +124 -229
- data/docs/plugins.md +28 -0
- data/docs/restart.md +39 -0
- data/docs/signals.md +56 -3
- data/docs/systemd.md +102 -37
- data/ext/puma_http11/http11_parser.c +130 -146
- data/ext/puma_http11/http11_parser.rl +9 -9
- data/ext/puma_http11/mini_ssl.c +2 -2
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +13 -16
- data/lib/puma/app/status.rb +8 -0
- data/lib/puma/binder.rb +6 -5
- data/lib/puma/client.rb +1 -0
- data/lib/puma/cluster.rb +8 -2
- data/lib/puma/configuration.rb +3 -2
- data/lib/puma/const.rb +3 -2
- data/lib/puma/control_cli.rb +2 -2
- data/lib/puma/dsl.rb +10 -0
- data/lib/puma/jruby_restart.rb +0 -1
- data/lib/puma/launcher.rb +31 -14
- data/lib/puma/minissl.rb +19 -25
- data/lib/puma/plugin/tmp_restart.rb +0 -1
- data/lib/puma/reactor.rb +3 -0
- data/lib/puma/server.rb +25 -19
- data/lib/puma/thread_pool.rb +2 -2
- data/lib/rack/handler/puma.rb +2 -0
- data/tools/jungle/README.md +4 -0
- data/tools/trickletest.rb +1 -1
- metadata +9 -57
- data/.github/issue_template.md +0 -20
- data/DEPLOYMENT.md +0 -91
- data/Gemfile +0 -14
- data/Manifest.txt +0 -78
- data/Rakefile +0 -165
- data/Release.md +0 -9
- data/gemfiles/2.1-Gemfile +0 -12
- data/puma.gemspec +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae7ad36143f718016374d543d84e480b182d0684
|
4
|
+
data.tar.gz: 4209350d304e18ee7144ff07461041479259a205
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 534b17d2b7ed7ad4917f7587707f7088d8b917d5ce0a08c5b31688088d0447fc013ca084adea61447c6c6463b99cada93ade7457fcd543b4240c72787b07d2dc
|
7
|
+
data.tar.gz: 24cd789a7a1233972c4b52d28743ababe5d3cee3cba963c45ec013cf3cd40f9c0388e40e9145538b5e414a2dc05e97a48a729fa5db3a0cf3f1838dc19da23aa9
|
data/History.md
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
## 3.10.0 / 2017-08-17
|
2
|
+
|
3
|
+
* 3 features:
|
4
|
+
* The status server has a new /gc and /gc-status command. (#1384)
|
5
|
+
* The persistent and first data timeouts are now configurable (#1111)
|
6
|
+
* Implemented RFC 2324 (#1392)
|
7
|
+
|
8
|
+
* 12 bugfixes:
|
9
|
+
* Not really a Puma bug, but @NickolasVashchenko created a gem to workaround a Ruby bug that some users of Puma may be experiencing. See README for more. (#1347)
|
10
|
+
* Fix hangups with SSL and persistent connections. (#1334)
|
11
|
+
* Fix Rails double-binding to a port (#1383)
|
12
|
+
* Fix incorrect thread names (#1368)
|
13
|
+
* Fix issues with /etc/hosts and JRuby where localhost addresses were not correct. (#1318)
|
14
|
+
* Fix compatibility with RUBYOPT="--enable-frozen-string-literal" (#1376)
|
15
|
+
* Fixed some compiler warnings (#1388)
|
16
|
+
* We actually run the integration tests in CI now (#1390)
|
17
|
+
* No longer shipping unnecessary directories in the gemfile (#1391)
|
18
|
+
* If RUBYOPT is nil, we no longer blow up on restart. (#1385)
|
19
|
+
* Correct response to SIGINT (#1377)
|
20
|
+
* Proper exit code returned when we receive a TERM signal (#1337)
|
21
|
+
|
22
|
+
* 3 refactors:
|
23
|
+
* Various test improvements from @grosser
|
24
|
+
* Rubocop (#1325)
|
25
|
+
* Hoe has been removed (#1395)
|
26
|
+
|
27
|
+
* 1 known issue:
|
28
|
+
* Socket activation doesn't work in JRuby. Their fault, not ours. (#1367)
|
29
|
+
|
1
30
|
## 3.9.1 / 2017-06-03
|
2
31
|
|
3
32
|
* 2 bugfixes:
|
data/README.md
CHANGED
@@ -1,344 +1,239 @@
|
|
1
|
+
<p align="center">
|
2
|
+
<img src="http://puma.io/images/logos/puma-logo-large.png">
|
3
|
+
</p>
|
4
|
+
|
1
5
|
# Puma: A Ruby Web Server Built For Concurrency
|
2
6
|
|
3
7
|
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/puma/puma?utm\_source=badge&utm\_medium=badge&utm\_campaign=pr-badge)
|
4
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)
|
5
10
|
[![Dependency Status](https://gemnasium.com/puma/puma.svg)](https://gemnasium.com/puma/puma)
|
6
11
|
[![Code Climate](https://codeclimate.com/github/puma/puma.svg)](https://codeclimate.com/github/puma/puma)
|
7
12
|
|
8
|
-
|
9
|
-
|
10
|
-
Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications. Puma is intended for use in both development and production environments. In order to get the best throughput, it is highly recommended that you use a Ruby implementation with real threads like Rubinius or JRuby.
|
13
|
+
Puma is a **simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications** in development and production.
|
11
14
|
|
12
15
|
## Built For Speed & Concurrency
|
13
16
|
|
14
|
-
Puma
|
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.
|
15
18
|
|
16
|
-
|
19
|
+
Puma was designed to be the go-to server for [Rubinius](http://rubini.us), but also works well with JRuby and MRI.
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
On MRI, there is a Global Interpreter Lock (GIL) that ensures only one thread can be run 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 (EventMachine-based servers such as Thin turn off this ability, requiring you to use special libraries). Your mileage may vary. In order to get the best throughput, it is highly recommended that you use a Ruby implementation with real threads like [Rubinius](http://rubini.us) or [JRuby](http://jruby.org).
|
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.
|
21
22
|
|
22
23
|
## Quick Start
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
Now you should have the `puma` command available in your PATH, so just do the following in the root folder of your Rack application:
|
29
|
-
|
30
|
-
$ puma app.ru
|
31
|
-
|
32
|
-
## Plugins
|
33
|
-
|
34
|
-
Puma 3.0 added support for plugins that can augment configuration and service operations.
|
35
|
-
|
36
|
-
2 canonical plugins to look to aid in development of further plugins:
|
37
|
-
|
38
|
-
* [tmp\_restart](https://github.com/puma/puma/blob/master/lib/puma/plugin/tmp_restart.rb): Restarts the server if the file `tmp/restart.txt` is touched
|
39
|
-
* [heroku](https://github.com/puma/puma-heroku/blob/master/lib/puma/plugin/heroku.rb): Packages up the default configuration used by puma on Heroku
|
40
|
-
|
41
|
-
Plugins are activated in a puma configuration file (such as `config/puma.rb'`) by adding `plugin "name"`, such as `plugin "heroku"`.
|
42
|
-
|
43
|
-
Plugins are activated based simply on path requirements so, activating the `heroku` plugin will simply be doing `require "puma/plugin/heroku"`. This allows gems to provide multiple plugins (as well as unrelated gems to provide puma plugins).
|
44
|
-
|
45
|
-
The `tmp_restart` plugin is bundled with puma, so it can always be used.
|
46
|
-
|
47
|
-
To use the `heroku` plugin, add `puma-heroku` to your Gemfile or install it.
|
48
|
-
|
49
|
-
### API
|
25
|
+
```
|
26
|
+
$ gem install puma
|
27
|
+
$ puma <any rackup (*.ru) file>
|
28
|
+
```
|
50
29
|
|
51
|
-
|
30
|
+
## Frameworks
|
52
31
|
|
53
|
-
|
32
|
+
### Rails
|
54
33
|
|
55
|
-
|
34
|
+
Puma is the default server for Rails, and should already be included in your Gemfile.
|
56
35
|
|
57
|
-
|
36
|
+
Then start your server with the `rails` command:
|
58
37
|
|
59
|
-
|
38
|
+
```
|
39
|
+
$ rails s
|
40
|
+
```
|
60
41
|
|
42
|
+
Many configuration options are not available when using `rails s`. It is recommended that you use Puma's executable instead:
|
61
43
|
|
62
|
-
|
44
|
+
```
|
45
|
+
$ bundle exec puma
|
46
|
+
```
|
63
47
|
|
64
48
|
### Sinatra
|
65
49
|
|
66
50
|
You can run your Sinatra application with Puma from the command line like this:
|
67
51
|
|
68
|
-
|
52
|
+
```
|
53
|
+
$ ruby app.rb -s Puma
|
54
|
+
```
|
69
55
|
|
70
56
|
Or you can configure your application to always use Puma:
|
71
57
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
### Rails
|
78
|
-
|
79
|
-
First, make sure Puma is in your Gemfile:
|
80
|
-
|
81
|
-
gem 'puma'
|
82
|
-
|
83
|
-
Then start your server with the `rails` command:
|
84
|
-
|
85
|
-
$ rails s Puma
|
86
|
-
|
87
|
-
### Rackup
|
88
|
-
|
89
|
-
You can pass it as an option to `rackup`:
|
90
|
-
|
91
|
-
$ rackup -s Puma
|
92
|
-
|
93
|
-
Alternatively, you can modify your `config.ru` to choose Puma by default, by adding the following as the first line:
|
94
|
-
|
95
|
-
#\ -s puma
|
58
|
+
```ruby
|
59
|
+
require 'sinatra'
|
60
|
+
configure { set :server, :puma }
|
61
|
+
```
|
96
62
|
|
97
63
|
## Configuration
|
98
64
|
|
99
|
-
Puma provides numerous options
|
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).
|
100
66
|
|
101
67
|
### Thread Pool
|
102
68
|
|
103
|
-
Puma
|
69
|
+
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:
|
104
70
|
|
105
|
-
|
71
|
+
```
|
72
|
+
$ puma -t 8:32
|
73
|
+
```
|
106
74
|
|
107
|
-
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
|
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).
|
108
76
|
|
109
77
|
### Clustered mode
|
110
78
|
|
111
|
-
Puma
|
112
|
-
|
113
|
-
$ puma -t 8:32 -w 3
|
79
|
+
Puma also offers "clustered mode". Clustered mode `fork`s workers from a master process. Each child process still has its own thread pool. You can tune the number of workers with the `-w` (or `--workers`) flag:
|
114
80
|
|
115
|
-
|
116
|
-
|
81
|
+
```
|
82
|
+
$ puma -t 8:32 -w 3
|
83
|
+
```
|
117
84
|
|
118
|
-
|
85
|
+
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.
|
119
86
|
|
120
|
-
|
121
|
-
$ puma -t 8:32 -w 3 --preload
|
87
|
+
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:
|
122
88
|
|
123
|
-
|
89
|
+
```
|
90
|
+
$ puma -w 3 --preload
|
91
|
+
```
|
124
92
|
|
125
|
-
|
93
|
+
If you're using a configuration file, use the `preload_app!` method:
|
126
94
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
95
|
+
```ruby
|
96
|
+
# config/puma.rb
|
97
|
+
workers 3
|
98
|
+
preload_app!
|
99
|
+
```
|
131
100
|
|
132
101
|
Additionally, you can specify a block in your configuration file that will be run on boot of each worker:
|
133
102
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
103
|
+
```ruby
|
104
|
+
# config/puma.rb
|
105
|
+
on_worker_boot do
|
106
|
+
# configuration here
|
107
|
+
end
|
108
|
+
```
|
138
109
|
|
139
110
|
This code can be used to setup the process before booting the application, allowing
|
140
111
|
you to do some Puma-specific things that you don't want to embed in your application.
|
141
112
|
For instance, you could fire a log notification that a worker booted or send something to statsd.
|
142
|
-
This can be called multiple times
|
113
|
+
This can be called multiple times.
|
143
114
|
|
144
115
|
If you're preloading your application and using ActiveRecord, it's recommended that you setup your connection pool here:
|
145
116
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
# config/puma.rb
|
156
|
-
before_fork do
|
157
|
-
# configuration here
|
158
|
-
end
|
159
|
-
|
160
|
-
This code can be used to clean up before forking to clients, allowing
|
161
|
-
you to do some Puma-specific things that you don't want to embed in your application.
|
162
|
-
|
163
|
-
If you're preloading your application and using ActiveRecord, it's recommended that you close any connections to the database here to prevent connection leakage:
|
164
|
-
|
165
|
-
# config/puma.rb
|
166
|
-
before_fork do
|
167
|
-
ActiveRecord::Base.connection_pool.disconnect!
|
168
|
-
end
|
169
|
-
|
170
|
-
This rule applies to any connections to external services (Redis, databases, memcache, ...) that might be started automatically by the framework.
|
171
|
-
|
172
|
-
When you use preload_app, all of your new code goes into the master process, and is then copied into the workers (meaning it’s only compatible with cluster mode). General rule is to use preload_app when your workers die often and need fast starts. If you don’t have many workers, you probably should not use preload_app.
|
173
|
-
|
174
|
-
Note that preload_app can’t be used with phased restart, since phased restart kills and restarts workers one-by-one, and preload_app is all about copying the code of master into the workers.
|
175
|
-
|
176
|
-
### Error handler for low-level errors
|
117
|
+
```ruby
|
118
|
+
# config/puma.rb
|
119
|
+
on_worker_boot do
|
120
|
+
ActiveSupport.on_load(:active_record) do
|
121
|
+
ActiveRecord::Base.establish_connection
|
122
|
+
end
|
123
|
+
end
|
124
|
+
```
|
177
125
|
|
178
|
-
|
179
|
-
textual error message (see `lowlevel_error` in [this file](https://github.com/puma/puma/blob/master/lib/puma/server.rb)).
|
180
|
-
You can specify custom behavior for this scenario. For example, you can report the error to your third-party
|
181
|
-
error-tracking service (in this example, [rollbar](http://rollbar.com)):
|
126
|
+
On top of that, you can specify a block in your configuration file that will be run before workers are forked:
|
182
127
|
|
183
128
|
```ruby
|
184
|
-
|
185
|
-
|
186
|
-
|
129
|
+
# config/puma.rb
|
130
|
+
before_fork do
|
131
|
+
# configuration here
|
187
132
|
end
|
188
133
|
```
|
189
134
|
|
135
|
+
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.
|
136
|
+
|
190
137
|
### Binding TCP / Sockets
|
191
138
|
|
192
139
|
In contrast to many other server configs which require multiple flags, Puma simply uses one URI parameter with the `-b` (or `--bind`) flag:
|
193
140
|
|
194
|
-
|
141
|
+
```
|
142
|
+
$ puma -b tcp://127.0.0.1:9292
|
143
|
+
```
|
195
144
|
|
196
|
-
Want to use UNIX Sockets instead of TCP (which can provide a 5-10% performance boost)?
|
145
|
+
Want to use UNIX Sockets instead of TCP (which can provide a 5-10% performance boost)?
|
197
146
|
|
198
|
-
|
147
|
+
```
|
148
|
+
$ puma -b unix:///var/run/puma.sock
|
149
|
+
```
|
199
150
|
|
200
151
|
If you need to change the permissions of the UNIX socket, just add a umask parameter:
|
201
152
|
|
202
|
-
|
153
|
+
```
|
154
|
+
$ puma -b 'unix:///var/run/puma.sock?umask=0111'
|
155
|
+
```
|
203
156
|
|
204
|
-
Need a bit of security? Use SSL sockets
|
157
|
+
Need a bit of security? Use SSL sockets:
|
205
158
|
|
206
|
-
|
159
|
+
```
|
160
|
+
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
|
161
|
+
```
|
207
162
|
|
208
163
|
### Control/Status Server
|
209
164
|
|
210
|
-
Puma
|
165
|
+
Puma has a built-in status/control app that can be used to query and control Puma itself.
|
211
166
|
|
212
|
-
|
167
|
+
```
|
168
|
+
$ puma --control tcp://127.0.0.1:9293 --control-token foo
|
169
|
+
```
|
213
170
|
|
214
|
-
|
171
|
+
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.
|
215
172
|
|
216
|
-
|
173
|
+
You can also interact with the control server via `pumactl`. This command will restart Puma:
|
217
174
|
|
218
|
-
|
175
|
+
```
|
176
|
+
$ pumactl restart --control-token foo
|
177
|
+
```
|
219
178
|
|
220
|
-
To see a list of `pumactl` options,
|
179
|
+
To see a list of `pumactl` options, use `pumactl --help`.
|
221
180
|
|
222
|
-
### Configuration
|
181
|
+
### Configuration File
|
223
182
|
|
224
183
|
You can also provide a configuration file which Puma will use with the `-C` (or `--config`) flag:
|
225
184
|
|
226
|
-
|
185
|
+
```
|
186
|
+
$ puma -C /path/to/config
|
187
|
+
```
|
227
188
|
|
228
|
-
|
189
|
+
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`.
|
229
190
|
|
230
191
|
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:
|
231
192
|
|
232
|
-
|
193
|
+
```
|
194
|
+
$ puma -C "-"
|
195
|
+
```
|
233
196
|
|
234
|
-
Take the following [sample configuration](https://github.com/puma/puma/blob/master/examples/config.rb) as inspiration or check out [
|
197
|
+
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.
|
235
198
|
|
236
199
|
## Restart
|
237
200
|
|
238
|
-
Puma includes the ability to restart itself
|
239
|
-
|
240
|
-
To perform a restart, there are 2 builtin mechanisms:
|
241
|
-
|
242
|
-
* Send the `puma` process the `SIGUSR2` signal
|
243
|
-
* Use the status server and issue `/restart`
|
244
|
-
|
245
|
-
No code is shared between the current and restarted process, so it should be safe to issue a restart any place where you would manually stop Puma and start it again.
|
246
|
-
|
247
|
-
If the new process is unable to load, it will simply exit. You should therefore run Puma under a process monitor (see below) when using it in production.
|
248
|
-
|
249
|
-
### Normal vs Hot vs Phased Restart
|
201
|
+
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.
|
250
202
|
|
251
|
-
|
203
|
+
For more, see the [restart documentation](https://github.com/puma/puma/blob/master/docs/restart.md).
|
252
204
|
|
253
|
-
|
205
|
+
## Signals
|
254
206
|
|
255
|
-
|
207
|
+
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).
|
256
208
|
|
257
|
-
|
209
|
+
## Platform Constraints
|
258
210
|
|
259
|
-
|
211
|
+
Some platforms do not support all Puma features.
|
260
212
|
|
261
|
-
|
213
|
+
* **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).
|
214
|
+
* **Windows**: daemon mode is not supported due to a lack of fork(2).
|
262
215
|
|
263
|
-
|
216
|
+
## Known Bugs
|
264
217
|
|
265
|
-
|
266
|
-
- `TTOU` decrement the worker count by 1
|
267
|
-
- `TERM` send `TERM` to worker. Worker will attempt to finish then exit.
|
268
|
-
- `USR2` restart workers
|
269
|
-
- `USR1` restart workers in phases, a rolling restart.
|
270
|
-
- `HUP` reopen log files defined in stdout_redirect configuration parameter
|
271
|
-
- `INT` equivalent of sending Ctrl-C to cluster. Will attempt to finish then exit.
|
272
|
-
- `CHLD`
|
273
|
-
|
274
|
-
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).
|
275
|
-
|
276
|
-
### Release Directory
|
277
|
-
|
278
|
-
If your symlink releases into a common working directory (i.e., `/current` from Capistrano), Puma won't pick up your new changes when running phased restarts without additional configuration. You should set your working directory within Puma's config to specify the directory it should use. This is a change from earlier versions of Puma (< 2.15) that would infer the directory for you.
|
218
|
+
For MRI versions 2.2.7, 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:
|
279
219
|
|
280
220
|
```ruby
|
281
|
-
|
282
|
-
|
283
|
-
|
221
|
+
if %w(2.2.7 2.3.4 2.4.1).include? RUBY_VERSION
|
222
|
+
gem "stopgap_13632", "~> 1.0", :platforms => ["mri", "mingw", "x64_mingw"]
|
223
|
+
end
|
284
224
|
```
|
285
225
|
|
286
|
-
|
287
|
-
|
288
|
-
Puma isn't able to understand all the resources that your app may use, so it provides a hook in the configuration file you pass to `-C` called `on_restart`. The block passed to `on_restart` will be called, unsurprisingly, just before Puma restarts itself.
|
289
|
-
|
290
|
-
You should place code to close global log files, redis connections, etc in this block so that their file descriptors don't leak into the restarted process. Failure to do so will result in slowly running out of descriptors and eventually obscure crashes as the server is restarted many times.
|
226
|
+
## Deployment
|
291
227
|
|
292
|
-
|
228
|
+
Puma has support for Capistrano with an [external gem](https://github.com/seuros/capistrano-puma).
|
293
229
|
|
294
|
-
|
295
|
-
|
296
|
-
* **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
|
297
|
-
* **JRuby**, **Windows**: cluster mode is not supported due to a lack of fork(2)
|
298
|
-
* **Windows**: daemon mode is not supported due to a lack of fork(2)
|
299
|
-
|
300
|
-
## pumactl
|
301
|
-
|
302
|
-
`pumactl` is a simple CLI frontend to the control/status app described above. Please refer to `pumactl --help` for available commands.
|
303
|
-
|
304
|
-
## Process Monitors
|
305
|
-
|
306
|
-
Process monitors or supervisors will at minimum provide start of Puma
|
307
|
-
on system boot. Modern process monitors like systemd or upstart
|
308
|
-
further provide continuous monitoring and restarts for increased
|
230
|
+
It is common to use process monitors with Puma. Modern process monitors like systemd or upstart
|
231
|
+
provide continuous monitoring and restarts for increased
|
309
232
|
reliability in production environments:
|
310
233
|
|
311
234
|
* [tools/jungle](https://github.com/puma/puma/tree/master/tools/jungle) for sysvinit (init.d) and upstart
|
312
235
|
* [docs/systemd](https://github.com/puma/puma/blob/master/docs/systemd.md)
|
313
236
|
|
314
|
-
## Capistrano deployment
|
315
|
-
|
316
|
-
Puma has support for Capistrano3 with an [external gem](https://github.com/seuros/capistrano-puma), you just need require that in Gemfile:
|
317
|
-
|
318
|
-
```ruby
|
319
|
-
gem 'capistrano3-puma'
|
320
|
-
```
|
321
|
-
And then execute:
|
322
|
-
|
323
|
-
```bash
|
324
|
-
bundle
|
325
|
-
```
|
326
|
-
|
327
|
-
Then add to Capfile
|
328
|
-
|
329
|
-
```ruby
|
330
|
-
require 'capistrano/puma'
|
331
|
-
```
|
332
|
-
|
333
|
-
and then
|
334
|
-
|
335
|
-
```bash
|
336
|
-
$ bundle exec cap puma:start
|
337
|
-
$ bundle exec cap puma:restart
|
338
|
-
$ bundle exec cap puma:stop
|
339
|
-
$ bundle exec cap puma:phased-restart
|
340
|
-
```
|
341
|
-
|
342
237
|
## Contributing
|
343
238
|
|
344
239
|
To run the test suite:
|
@@ -350,4 +245,4 @@ $ bundle exec rake
|
|
350
245
|
|
351
246
|
## License
|
352
247
|
|
353
|
-
Puma is copyright
|
248
|
+
Puma is copyright Evan Phoenix and contributors, licensed under the BSD 3-Clause license. See the included LICENSE file for details.
|