puma 5.4.0 → 5.5.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puma might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/History.md +40 -2
- data/README.md +42 -6
- data/docs/architecture.md +49 -16
- data/docs/compile_options.md +4 -2
- data/docs/deployment.md +53 -52
- data/docs/plugins.md +15 -15
- data/docs/rails_dev_mode.md +2 -3
- data/docs/restart.md +6 -6
- data/docs/signals.md +10 -10
- data/docs/stats.md +8 -8
- data/docs/systemd.md +64 -67
- data/ext/puma_http11/http11_parser.c +19 -12
- data/ext/puma_http11/http11_parser_common.rl +1 -1
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +34 -34
- data/lib/puma/binder.rb +29 -1
- data/lib/puma/cli.rb +5 -0
- data/lib/puma/client.rb +45 -3
- data/lib/puma/cluster/worker.rb +2 -12
- data/lib/puma/cluster.rb +0 -10
- data/lib/puma/configuration.rb +1 -1
- data/lib/puma/const.rb +4 -2
- data/lib/puma/control_cli.rb +1 -1
- data/lib/puma/dsl.rb +13 -3
- data/lib/puma/launcher.rb +2 -0
- data/lib/puma/minissl.rb +6 -21
- data/lib/puma/runner.rb +19 -6
- data/lib/puma/server.rb +14 -7
- data/lib/puma/util.rb +7 -0
- metadata +5 -5
data/docs/stats.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
##
|
1
|
+
## Accessing stats
|
2
2
|
|
3
3
|
Stats can be accessed in two ways:
|
4
4
|
|
@@ -47,18 +47,18 @@ end
|
|
47
47
|
|
48
48
|
## Explanation of stats
|
49
49
|
|
50
|
-
`Puma.stats` returns different information and a different structure depending on if Puma is in single vs cluster mode. There is one top-level attribute that is common to both modes:
|
50
|
+
`Puma.stats` returns different information and a different structure depending on if Puma is in single vs. cluster mode. There is one top-level attribute that is common to both modes:
|
51
51
|
|
52
|
-
* started_at: when
|
52
|
+
* started_at: when Puma was started
|
53
53
|
|
54
54
|
### single mode and individual workers in cluster mode
|
55
55
|
|
56
|
-
When Puma
|
56
|
+
When Puma runs in single mode, these stats are available at the top level. When Puma runs in cluster mode, these stats are available within the `worker_status` array in a hash labeled `last_status`, in an array of hashes where one hash represents each worker.
|
57
57
|
|
58
58
|
* backlog: requests that are waiting for an available thread to be available. if this is above 0, you need more capacity [always true?]
|
59
59
|
* running: how many threads are running
|
60
|
-
* pool_capacity: the number of requests that the server is capable of taking right now. For example if the number is 5 then it means there are 5 threads sitting idle ready to take a request. If one request comes in, then the value would be 4 until it finishes processing. If the minimum threads allowed is zero, this number will still have a maximum value of the maximum threads allowed.
|
61
|
-
* max_threads: the maximum number of threads
|
60
|
+
* pool_capacity: the number of requests that the server is capable of taking right now. For example, if the number is 5, then it means there are 5 threads sitting idle ready to take a request. If one request comes in, then the value would be 4 until it finishes processing. If the minimum threads allowed is zero, this number will still have a maximum value of the maximum threads allowed.
|
61
|
+
* max_threads: the maximum number of threads Puma is configured to spool per worker
|
62
62
|
* requests_count: the number of requests this worker has served since starting
|
63
63
|
|
64
64
|
|
@@ -72,9 +72,9 @@ When Puma is run in single mode, these stats are available at the top level. Whe
|
|
72
72
|
|
73
73
|
### worker status
|
74
74
|
|
75
|
-
* started_at: when the worker
|
75
|
+
* started_at: when the worker started
|
76
76
|
* pid: the process id of the worker process
|
77
|
-
* index: each worker gets a number. if
|
77
|
+
* index: each worker gets a number. if Puma is configured to have 3 workers, then this will be 0, 1, or 2
|
78
78
|
* booted: if it's done booting [?]
|
79
79
|
* last_checkin: Last time the worker responded to the master process' heartbeat check.
|
80
80
|
* last_status: a hash of info about the worker's state handling requests. See the explanation for this in "single mode and individual workers in cluster mode" section above.
|
data/docs/systemd.md
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
# systemd
|
2
2
|
|
3
|
-
[systemd](https://www.freedesktop.org/wiki/Software/systemd/) is a
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
[systemd](https://www.freedesktop.org/wiki/Software/systemd/) is a commonly
|
4
|
+
available init system (PID 1) on many Linux distributions. It offers process
|
5
|
+
monitoring (including automatic restarts) and other useful features for running
|
6
|
+
Puma in production.
|
7
7
|
|
8
8
|
## Service Configuration
|
9
9
|
|
10
|
-
Below is a sample puma.service configuration file for systemd, which
|
11
|
-
|
12
|
-
|
10
|
+
Below is a sample puma.service configuration file for systemd, which can be
|
11
|
+
copied or symlinked to `/etc/systemd/system/puma.service`, or if desired, using
|
12
|
+
an application or instance-specific name.
|
13
13
|
|
14
|
-
Note that this uses the systemd preferred "simple" type where the
|
15
|
-
|
16
|
-
exit).
|
14
|
+
Note that this uses the systemd preferred "simple" type where the start command
|
15
|
+
remains running in the foreground (does not fork and exit).
|
17
16
|
|
18
17
|
~~~~ ini
|
19
18
|
[Unit]
|
@@ -37,8 +36,8 @@ WatchdogSec=10
|
|
37
36
|
# Preferably configure a non-privileged user
|
38
37
|
# User=
|
39
38
|
|
40
|
-
# The path to
|
41
|
-
# Also replace the "<YOUR_APP_PATH>"
|
39
|
+
# The path to your application code root directory.
|
40
|
+
# Also replace the "<YOUR_APP_PATH>" placeholders below with this path.
|
42
41
|
# Example /home/username/myapp
|
43
42
|
WorkingDirectory=<YOUR_APP_PATH>
|
44
43
|
|
@@ -64,33 +63,31 @@ Restart=always
|
|
64
63
|
WantedBy=multi-user.target
|
65
64
|
~~~~
|
66
65
|
|
67
|
-
See
|
66
|
+
See
|
67
|
+
[systemd.exec](https://www.freedesktop.org/software/systemd/man/systemd.exec.html)
|
68
68
|
for additional details.
|
69
69
|
|
70
70
|
## Socket Activation
|
71
71
|
|
72
|
-
systemd and
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
`Requires` directive for the socket unit in the service file (see
|
92
|
-
above.) Here is a sample puma.socket, matching the ports used in the
|
93
|
-
above puma.service:
|
72
|
+
systemd and Puma also support socket activation, where systemd opens the
|
73
|
+
listening socket(s) in advance and provides them to the Puma master process on
|
74
|
+
startup. Among other advantages, this keeps listening sockets open across puma
|
75
|
+
restarts and achieves graceful restarts, including when upgraded Puma, and is
|
76
|
+
compatible with both clustered mode and application preload.
|
77
|
+
|
78
|
+
**Note:** Any wrapper scripts which `exec`, or other indirections in `ExecStart`
|
79
|
+
may result in activated socket file descriptors being closed before reaching the
|
80
|
+
puma master process. For example, if using `bundle exec`, pass the
|
81
|
+
`--keep-file-descriptors` flag. `bundle exec` can be avoided by using a `puma`
|
82
|
+
executable generated by `bundle binstubs puma`. This is tracked in [#1499].
|
83
|
+
|
84
|
+
**Note:** Socket activation doesn't currently work on JRuby. This is tracked in
|
85
|
+
[#1367].
|
86
|
+
|
87
|
+
Configure one or more `ListenStream` sockets in a companion `*.socket` unit file
|
88
|
+
to use socket activation. Also, uncomment the associated `Requires` directive
|
89
|
+
for the socket unit in the service file (see above.) Here is a sample
|
90
|
+
puma.socket, matching the ports used in the above puma.service:
|
94
91
|
|
95
92
|
~~~~ ini
|
96
93
|
[Unit]
|
@@ -113,31 +110,32 @@ Backlog=1024
|
|
113
110
|
WantedBy=sockets.target
|
114
111
|
~~~~
|
115
112
|
|
116
|
-
See
|
113
|
+
See
|
114
|
+
[systemd.socket](https://www.freedesktop.org/software/systemd/man/systemd.socket.html)
|
117
115
|
for additional configuration details.
|
118
116
|
|
119
|
-
Note that the above configurations will work with Puma in either
|
120
|
-
|
117
|
+
Note that the above configurations will work with Puma in either single process
|
118
|
+
or cluster mode.
|
121
119
|
|
122
120
|
### Sockets and symlinks
|
123
121
|
|
124
|
-
When using releases folders, you should set the socket path using the
|
125
|
-
|
126
|
-
|
122
|
+
When using releases folders, you should set the socket path using the shared
|
123
|
+
folder path (ex. `/srv/projet/shared/tmp/puma.sock`), not the release folder
|
124
|
+
path (`/srv/projet/releases/1234/tmp/puma.sock`).
|
127
125
|
|
128
126
|
Puma will detect the release path socket as different than the one provided by
|
129
|
-
systemd and attempt to bind it again, resulting in the exception
|
130
|
-
|
127
|
+
systemd and attempt to bind it again, resulting in the exception `There is
|
128
|
+
already a server bound to:`.
|
131
129
|
|
132
130
|
### Binding
|
133
131
|
|
134
|
-
By default you need to configure
|
132
|
+
By default, you need to configure Puma to have binds matching with all
|
135
133
|
ListenStream statements. Any mismatched systemd ListenStreams will be closed by
|
136
|
-
|
134
|
+
Puma.
|
137
135
|
|
138
136
|
To automatically bind to all activated sockets, the option
|
139
137
|
`--bind-to-activated-sockets` can be used. This matches the config DSL
|
140
|
-
`bind_to_activated_sockets` statement. This will cause
|
138
|
+
`bind_to_activated_sockets` statement. This will cause Puma to create a bind
|
141
139
|
automatically for any activated socket. When systemd socket activation is not
|
142
140
|
enabled, this option does nothing.
|
143
141
|
|
@@ -146,8 +144,8 @@ binds that's not socket activated.
|
|
146
144
|
|
147
145
|
## Usage
|
148
146
|
|
149
|
-
Without socket activation, use `systemctl` as root (e
|
150
|
-
|
147
|
+
Without socket activation, use `systemctl` as root (i.e., via `sudo`) as with
|
148
|
+
other system services:
|
151
149
|
|
152
150
|
~~~~ sh
|
153
151
|
# After installing or making changes to puma.service
|
@@ -156,35 +154,35 @@ systemctl daemon-reload
|
|
156
154
|
# Enable so it starts on boot
|
157
155
|
systemctl enable puma.service
|
158
156
|
|
159
|
-
# Initial
|
157
|
+
# Initial startup.
|
160
158
|
systemctl start puma.service
|
161
159
|
|
162
160
|
# Check status
|
163
161
|
systemctl status puma.service
|
164
162
|
|
165
|
-
# A normal restart. Warning:
|
163
|
+
# A normal restart. Warning: listener's sockets will be closed
|
166
164
|
# while a new puma process initializes.
|
167
165
|
systemctl restart puma.service
|
168
166
|
~~~~
|
169
167
|
|
170
|
-
With socket activation, several but not all of these commands should
|
171
|
-
|
168
|
+
With socket activation, several but not all of these commands should be run for
|
169
|
+
both socket and service:
|
172
170
|
|
173
171
|
~~~~ sh
|
174
172
|
# After installing or making changes to either puma.socket or
|
175
173
|
# puma.service.
|
176
174
|
systemctl daemon-reload
|
177
175
|
|
178
|
-
# Enable both socket and service so they start on boot. Alternatively
|
179
|
-
# you could leave puma.service disabled and systemd will start it on
|
180
|
-
# first use (with startup lag on first request)
|
176
|
+
# Enable both socket and service, so they start on boot. Alternatively
|
177
|
+
# you could leave puma.service disabled, and systemd will start it on
|
178
|
+
# the first use (with startup lag on the first request)
|
181
179
|
systemctl enable puma.socket puma.service
|
182
180
|
|
183
|
-
# Initial
|
181
|
+
# Initial startup. The Requires directive (see above) ensures the
|
184
182
|
# socket is started before the service.
|
185
183
|
systemctl start puma.socket puma.service
|
186
184
|
|
187
|
-
# Check status of both socket and service.
|
185
|
+
# Check the status of both socket and service.
|
188
186
|
systemctl status puma.socket puma.service
|
189
187
|
|
190
188
|
# A "hot" restart, with systemd keeping puma.socket listening and
|
@@ -197,8 +195,8 @@ systemctl restart puma.service
|
|
197
195
|
systemctl restart puma.socket puma.service
|
198
196
|
~~~~
|
199
197
|
|
200
|
-
Here is sample output from `systemctl status` with both service and
|
201
|
-
|
198
|
+
Here is sample output from `systemctl status` with both service and socket
|
199
|
+
running:
|
202
200
|
|
203
201
|
~~~~
|
204
202
|
● puma.socket - Puma HTTP Server Accept Sockets
|
@@ -231,14 +229,12 @@ Apr 07 08:40:19 hx puma[28320]: Use Ctrl-C to stop
|
|
231
229
|
|
232
230
|
### capistrano3-puma
|
233
231
|
|
234
|
-
By default,
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
also that the configured `User` should likely be the same as the
|
241
|
-
capistrano3-puma `:puma_user` option.
|
232
|
+
By default, [capistrano3-puma](https://github.com/seuros/capistrano-puma) uses
|
233
|
+
`pumactl` for deployment restarts outside of systemd. To learn the exact
|
234
|
+
commands that this tool would use for `ExecStart` and `ExecStop`, use the
|
235
|
+
following `cap` commands in dry-run mode, and update from the above forking
|
236
|
+
service configuration accordingly. Note also that the configured `User` should
|
237
|
+
likely be the same as the capistrano3-puma `:puma_user` option.
|
242
238
|
|
243
239
|
~~~~ sh
|
244
240
|
stage=production # or different stage, as needed
|
@@ -248,3 +244,4 @@ cap $stage puma:stop --dry-run
|
|
248
244
|
|
249
245
|
[Restart]: https://www.freedesktop.org/software/systemd/man/systemd.service.html#Restart=
|
250
246
|
[#1367]: https://github.com/puma/puma/issues/1367
|
247
|
+
[#1499]: https://github.com/puma/puma/issues/1499
|
@@ -426,10 +426,13 @@ st18:
|
|
426
426
|
case 18:
|
427
427
|
#line 428 "ext/puma_http11/http11_parser.c"
|
428
428
|
switch( (*p) ) {
|
429
|
+
case 9: goto tr25;
|
429
430
|
case 13: goto tr26;
|
430
431
|
case 32: goto tr27;
|
431
432
|
}
|
432
|
-
|
433
|
+
if ( 33 <= (*p) && (*p) <= 126 )
|
434
|
+
goto tr25;
|
435
|
+
goto st0;
|
433
436
|
tr25:
|
434
437
|
#line 46 "ext/puma_http11/http11_parser.rl"
|
435
438
|
{ MARK(mark, p); }
|
@@ -438,10 +441,14 @@ st19:
|
|
438
441
|
if ( ++p == pe )
|
439
442
|
goto _test_eof19;
|
440
443
|
case 19:
|
441
|
-
#line
|
442
|
-
|
443
|
-
goto
|
444
|
-
|
444
|
+
#line 445 "ext/puma_http11/http11_parser.c"
|
445
|
+
switch( (*p) ) {
|
446
|
+
case 9: goto st19;
|
447
|
+
case 13: goto tr29;
|
448
|
+
}
|
449
|
+
if ( 32 <= (*p) && (*p) <= 126 )
|
450
|
+
goto st19;
|
451
|
+
goto st0;
|
445
452
|
tr9:
|
446
453
|
#line 53 "ext/puma_http11/http11_parser.rl"
|
447
454
|
{
|
@@ -484,7 +491,7 @@ st20:
|
|
484
491
|
if ( ++p == pe )
|
485
492
|
goto _test_eof20;
|
486
493
|
case 20:
|
487
|
-
#line
|
494
|
+
#line 495 "ext/puma_http11/http11_parser.c"
|
488
495
|
switch( (*p) ) {
|
489
496
|
case 32: goto tr31;
|
490
497
|
case 60: goto st0;
|
@@ -505,7 +512,7 @@ st21:
|
|
505
512
|
if ( ++p == pe )
|
506
513
|
goto _test_eof21;
|
507
514
|
case 21:
|
508
|
-
#line
|
515
|
+
#line 516 "ext/puma_http11/http11_parser.c"
|
509
516
|
switch( (*p) ) {
|
510
517
|
case 32: goto tr33;
|
511
518
|
case 60: goto st0;
|
@@ -526,7 +533,7 @@ st22:
|
|
526
533
|
if ( ++p == pe )
|
527
534
|
goto _test_eof22;
|
528
535
|
case 22:
|
529
|
-
#line
|
536
|
+
#line 537 "ext/puma_http11/http11_parser.c"
|
530
537
|
switch( (*p) ) {
|
531
538
|
case 43: goto st22;
|
532
539
|
case 58: goto st23;
|
@@ -551,7 +558,7 @@ st23:
|
|
551
558
|
if ( ++p == pe )
|
552
559
|
goto _test_eof23;
|
553
560
|
case 23:
|
554
|
-
#line
|
561
|
+
#line 562 "ext/puma_http11/http11_parser.c"
|
555
562
|
switch( (*p) ) {
|
556
563
|
case 32: goto tr8;
|
557
564
|
case 34: goto st0;
|
@@ -571,7 +578,7 @@ st24:
|
|
571
578
|
if ( ++p == pe )
|
572
579
|
goto _test_eof24;
|
573
580
|
case 24:
|
574
|
-
#line
|
581
|
+
#line 582 "ext/puma_http11/http11_parser.c"
|
575
582
|
switch( (*p) ) {
|
576
583
|
case 32: goto tr37;
|
577
584
|
case 34: goto st0;
|
@@ -594,7 +601,7 @@ st25:
|
|
594
601
|
if ( ++p == pe )
|
595
602
|
goto _test_eof25;
|
596
603
|
case 25:
|
597
|
-
#line
|
604
|
+
#line 605 "ext/puma_http11/http11_parser.c"
|
598
605
|
switch( (*p) ) {
|
599
606
|
case 32: goto tr41;
|
600
607
|
case 34: goto st0;
|
@@ -614,7 +621,7 @@ st26:
|
|
614
621
|
if ( ++p == pe )
|
615
622
|
goto _test_eof26;
|
616
623
|
case 26:
|
617
|
-
#line
|
624
|
+
#line 625 "ext/puma_http11/http11_parser.c"
|
618
625
|
switch( (*p) ) {
|
619
626
|
case 32: goto tr44;
|
620
627
|
case 34: goto st0;
|
@@ -43,7 +43,7 @@
|
|
43
43
|
|
44
44
|
field_name = ( token -- ":" )+ >start_field $snake_upcase_field %write_field;
|
45
45
|
|
46
|
-
field_value =
|
46
|
+
field_value = ( print | "\t" )* >start_value %write_value;
|
47
47
|
|
48
48
|
message_header = field_name ":" " "* field_value :> CRLF;
|
49
49
|
|
@@ -34,9 +34,9 @@ private static short[] init__puma_parser_key_offsets_0()
|
|
34
34
|
{
|
35
35
|
return new short [] {
|
36
36
|
0, 0, 8, 17, 27, 29, 30, 31, 32, 33, 34, 36,
|
37
|
-
39, 41, 44, 45, 61, 62, 78,
|
38
|
-
|
39
|
-
|
37
|
+
39, 41, 44, 45, 61, 62, 78, 83, 87, 95, 103, 113,
|
38
|
+
121, 130, 138, 146, 155, 164, 173, 182, 191, 200, 209, 218,
|
39
|
+
227, 236, 245, 254, 263, 272, 281, 290, 299, 308, 309
|
40
40
|
};
|
41
41
|
}
|
42
42
|
|
@@ -52,14 +52,13 @@ private static char[] init__puma_parser_trans_keys_0()
|
|
52
52
|
46, 48, 57, 48, 57, 13, 48, 57, 10, 13, 33, 124,
|
53
53
|
126, 35, 39, 42, 43, 45, 46, 48, 57, 65, 90, 94,
|
54
54
|
122, 10, 33, 58, 124, 126, 35, 39, 42, 43, 45, 46,
|
55
|
-
48, 57, 65, 90, 94, 122, 13, 32,
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32,
|
55
|
+
48, 57, 65, 90, 94, 122, 9, 13, 32, 33, 126, 9,
|
56
|
+
13, 32, 126, 32, 60, 62, 127, 0, 31, 34, 35, 32,
|
57
|
+
60, 62, 127, 0, 31, 34, 35, 43, 58, 45, 46, 48,
|
58
|
+
57, 65, 90, 97, 122, 32, 34, 35, 60, 62, 127, 0,
|
59
|
+
31, 32, 34, 35, 60, 62, 63, 127, 0, 31, 32, 34,
|
60
|
+
35, 60, 62, 127, 0, 31, 32, 34, 35, 60, 62, 127,
|
61
|
+
0, 31, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32,
|
63
62
|
36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45,
|
64
63
|
46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57,
|
65
64
|
65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32,
|
@@ -71,7 +70,8 @@ private static char[] init__puma_parser_trans_keys_0()
|
|
71
70
|
65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32,
|
72
71
|
36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45,
|
73
72
|
46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57,
|
74
|
-
65, 90, 32,
|
73
|
+
65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32,
|
74
|
+
36, 95, 45, 46, 48, 57, 65, 90, 32, 0
|
75
75
|
};
|
76
76
|
}
|
77
77
|
|
@@ -82,7 +82,7 @@ private static byte[] init__puma_parser_single_lengths_0()
|
|
82
82
|
{
|
83
83
|
return new byte [] {
|
84
84
|
0, 2, 3, 4, 2, 1, 1, 1, 1, 1, 0, 1,
|
85
|
-
0, 1, 1, 4, 1, 4,
|
85
|
+
0, 1, 1, 4, 1, 4, 3, 2, 4, 4, 2, 6,
|
86
86
|
7, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
87
87
|
3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0
|
88
88
|
};
|
@@ -95,7 +95,7 @@ private static byte[] init__puma_parser_range_lengths_0()
|
|
95
95
|
{
|
96
96
|
return new byte [] {
|
97
97
|
0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1,
|
98
|
-
1, 1, 0, 6, 0, 6,
|
98
|
+
1, 1, 0, 6, 0, 6, 1, 1, 2, 2, 4, 1,
|
99
99
|
1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
100
100
|
3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0
|
101
101
|
};
|
@@ -108,9 +108,9 @@ private static short[] init__puma_parser_index_offsets_0()
|
|
108
108
|
{
|
109
109
|
return new short [] {
|
110
110
|
0, 0, 6, 13, 21, 24, 26, 28, 30, 32, 34, 36,
|
111
|
-
39, 41, 44, 46, 57, 59, 70,
|
112
|
-
|
113
|
-
|
111
|
+
39, 41, 44, 46, 57, 59, 70, 75, 79, 86, 93, 100,
|
112
|
+
108, 117, 125, 133, 140, 147, 154, 161, 168, 175, 182, 189,
|
113
|
+
196, 203, 210, 217, 224, 231, 238, 245, 252, 259, 261
|
114
114
|
};
|
115
115
|
}
|
116
116
|
|
@@ -125,23 +125,23 @@ private static byte[] init__puma_parser_indicies_0()
|
|
125
125
|
10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1,
|
126
126
|
16, 15, 1, 17, 1, 18, 17, 1, 19, 1, 20, 21,
|
127
127
|
21, 21, 21, 21, 21, 21, 21, 21, 1, 22, 1, 23,
|
128
|
-
24, 23, 23, 23, 23, 23, 23, 23, 23, 1,
|
129
|
-
|
130
|
-
1, 1, 1, 1, 33, 34, 35, 34,
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
46, 46, 46, 1, 2, 47, 47, 47,
|
135
|
-
48, 48, 48, 48, 48, 1, 2, 49,
|
136
|
-
|
137
|
-
|
138
|
-
53, 53, 53, 53, 1, 2, 54, 54,
|
139
|
-
|
140
|
-
56, 1, 2, 57, 57, 57, 57, 57,
|
141
|
-
|
142
|
-
60, 60, 60, 60, 60, 1, 2, 61,
|
143
|
-
|
144
|
-
|
128
|
+
24, 23, 23, 23, 23, 23, 23, 23, 23, 1, 25, 26,
|
129
|
+
27, 25, 1, 28, 29, 28, 1, 30, 1, 1, 1, 1,
|
130
|
+
1, 31, 32, 1, 1, 1, 1, 1, 33, 34, 35, 34,
|
131
|
+
34, 34, 34, 1, 8, 1, 9, 1, 1, 1, 1, 35,
|
132
|
+
36, 1, 38, 1, 1, 39, 1, 1, 37, 40, 1, 42,
|
133
|
+
1, 1, 1, 1, 41, 43, 1, 45, 1, 1, 1, 1,
|
134
|
+
44, 2, 46, 46, 46, 46, 46, 1, 2, 47, 47, 47,
|
135
|
+
47, 47, 1, 2, 48, 48, 48, 48, 48, 1, 2, 49,
|
136
|
+
49, 49, 49, 49, 1, 2, 50, 50, 50, 50, 50, 1,
|
137
|
+
2, 51, 51, 51, 51, 51, 1, 2, 52, 52, 52, 52,
|
138
|
+
52, 1, 2, 53, 53, 53, 53, 53, 1, 2, 54, 54,
|
139
|
+
54, 54, 54, 1, 2, 55, 55, 55, 55, 55, 1, 2,
|
140
|
+
56, 56, 56, 56, 56, 1, 2, 57, 57, 57, 57, 57,
|
141
|
+
1, 2, 58, 58, 58, 58, 58, 1, 2, 59, 59, 59,
|
142
|
+
59, 59, 1, 2, 60, 60, 60, 60, 60, 1, 2, 61,
|
143
|
+
61, 61, 61, 61, 1, 2, 62, 62, 62, 62, 62, 1,
|
144
|
+
2, 63, 63, 63, 63, 63, 1, 2, 1, 1, 0
|
145
145
|
};
|
146
146
|
}
|
147
147
|
|
data/lib/puma/binder.rb
CHANGED
@@ -57,6 +57,7 @@ module Puma
|
|
57
57
|
|
58
58
|
@envs = {}
|
59
59
|
@ios = []
|
60
|
+
localhost_authority
|
60
61
|
end
|
61
62
|
|
62
63
|
attr_reader :ios
|
@@ -227,7 +228,13 @@ module Puma
|
|
227
228
|
raise "Puma compiled without SSL support" unless HAS_SSL
|
228
229
|
|
229
230
|
params = Util.parse_query uri.query
|
230
|
-
|
231
|
+
|
232
|
+
# If key and certs are not defined and localhost gem is required.
|
233
|
+
# localhost gem will be used for self signed
|
234
|
+
# Load localhost authority if not loaded.
|
235
|
+
ctx = localhost_authority && localhost_authority_context if params.empty?
|
236
|
+
|
237
|
+
ctx ||= MiniSSL::ContextBuilder.new(params, @events).context
|
231
238
|
|
232
239
|
if fd = @inherited_fds.delete(str)
|
233
240
|
logger.log "* Inherited #{str}"
|
@@ -285,6 +292,22 @@ module Puma
|
|
285
292
|
end
|
286
293
|
end
|
287
294
|
|
295
|
+
def localhost_authority
|
296
|
+
@localhost_authority ||= Localhost::Authority.fetch if defined?(Localhost::Authority) && !Puma::IS_JRUBY
|
297
|
+
end
|
298
|
+
|
299
|
+
def localhost_authority_context
|
300
|
+
return unless localhost_authority
|
301
|
+
|
302
|
+
key_path, crt_path = if [:key_path, :certificate_path].all? { |m| localhost_authority.respond_to?(m) }
|
303
|
+
[localhost_authority.key_path, localhost_authority.certificate_path]
|
304
|
+
else
|
305
|
+
local_certificates_path = File.expand_path("~/.localhost")
|
306
|
+
[File.join(local_certificates_path, "localhost.key"), File.join(local_certificates_path, "localhost.crt")]
|
307
|
+
end
|
308
|
+
MiniSSL::ContextBuilder.new({ "key" => key_path, "cert" => crt_path }, @events).context
|
309
|
+
end
|
310
|
+
|
288
311
|
# Tell the server to listen on host +host+, port +port+.
|
289
312
|
# If +optimize_for_latency+ is true (the default) then clients connecting
|
290
313
|
# will be optimized for latency over throughput.
|
@@ -302,6 +325,7 @@ module Puma
|
|
302
325
|
|
303
326
|
host = host[1..-2] if host and host[0..0] == '['
|
304
327
|
tcp_server = TCPServer.new(host, port)
|
328
|
+
|
305
329
|
if optimize_for_latency
|
306
330
|
tcp_server.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
307
331
|
end
|
@@ -323,6 +347,8 @@ module Puma
|
|
323
347
|
optimize_for_latency=true, backlog=1024)
|
324
348
|
|
325
349
|
raise "Puma compiled without SSL support" unless HAS_SSL
|
350
|
+
# Puma will try to use local authority context if context is supplied nil
|
351
|
+
ctx ||= localhost_authority_context
|
326
352
|
|
327
353
|
if host == "localhost"
|
328
354
|
loopback_addresses.each do |addr|
|
@@ -350,6 +376,8 @@ module Puma
|
|
350
376
|
|
351
377
|
def inherit_ssl_listener(fd, ctx)
|
352
378
|
raise "Puma compiled without SSL support" unless HAS_SSL
|
379
|
+
# Puma will try to use local authority context if context is supplied nil
|
380
|
+
ctx ||= localhost_authority_context
|
353
381
|
|
354
382
|
s = fd.kind_of?(::TCPServer) ? fd : ::TCPServer.for_fd(fd)
|
355
383
|
|
data/lib/puma/cli.rb
CHANGED
@@ -112,6 +112,11 @@ module Puma
|
|
112
112
|
file_config.load arg
|
113
113
|
end
|
114
114
|
|
115
|
+
# Identical to supplying --config "-", but more semantic
|
116
|
+
o.on "--no-config", "Prevent Puma from searching for a config file" do |arg|
|
117
|
+
file_config.load "-"
|
118
|
+
end
|
119
|
+
|
115
120
|
o.on "--control-url URL", "The bind url to use for the control server. Use 'auto' to use temp unix server" do |arg|
|
116
121
|
configure_control_url(arg)
|
117
122
|
end
|