puma 4.1.1 → 4.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e85f11b3b0951de326c5bba3f9f11c77bd1f4b28d6bc82d0f33ba8c6f7ebfd2d
4
- data.tar.gz: 481c1977d845730e2fe5f1186861b6e31f6fe5141f9b90b1d5269a4fcb293657
3
+ metadata.gz: a3b55d391fabcf1d06ef5dec1bf340baa8f79bb259eda2c82b00f325fc43575a
4
+ data.tar.gz: c880b55b1277a9046d92c761dcf60d7bff9a059c9a0d54985607919c50a0653a
5
5
  SHA512:
6
- metadata.gz: 25f5a271f646bb1d4695279a5fa21a5be43639a01bcd6647adc484f84e84fc2a227097278da57456bf81de4996c749c0f6c80f9fd249e24a79555e44431bb19b
7
- data.tar.gz: 2defc82769f5c36810f21aaf3f93aaad52e9073e55cb8f19aa0dbc4cfc2dcab37fd0cf458aef58b2025626ff4a59174aff7fa0faa9ebe5a3333fa7dd69ff5df7
6
+ metadata.gz: d384912b42fd6e839793c912c1bf534aae25a29b03ec1eaaaad3b8ececc786f3f72df22194479c38720d01c9463bf7868fb19ade35a3fe399f17f2757a99612d
7
+ data.tar.gz: 7b6b2f827c6c4c2bf33f6a88f00f8cae55a36b4f7bffe6b36c3d98d880e9f83c6c75398ded27c1ab1e5e6e1bad2dbc3f72713abcc1d37ba60ccdfb8d1c7764c1
data/History.md CHANGED
@@ -6,6 +6,23 @@
6
6
  * Bugfixes
7
7
  * Your bugfix goes here (#Github Number)
8
8
 
9
+
10
+ ## 4.2.0 / 2019-09-23
11
+
12
+ * 6 features
13
+ * Pumactl has a new -e environment option and reads config/puma/<environment>.rb config files (#1885)
14
+ * Semicolons are now allowed in URL paths (MRI only), useful for Angular or Redmine (#1934)
15
+ * Allow extra dependencies to be defined when using prune_bundler (#1105)
16
+ * Puma now reports the correct port when binding to port 0, also reports other listeners when binding to localhost (#1786)
17
+ * Sending SIGINFO to any Puma worker now prints currently active threads and their backtraces (#1320)
18
+ * Puma threads all now have their name set on Ruby 2.3+ (#1968)
19
+ * 4 bugfixes
20
+ * Fix some misbehavior with phased restart and externally SIGTERMed workers (#1908, #1952)
21
+ * Fix socket closing on error (#1941)
22
+ * Removed unnecessary SIGINT trap for JRuby that caused some race conditions (#1961)
23
+ * Fix socket files being left around after process stopped (#1970)
24
+ * Absolutely thousands of lines of test improvements and fixes thanks to @MSP-Greg
25
+
9
26
  ## 4.1.1 / 2019-09-05
10
27
 
11
28
  * 3 bugfixes
@@ -15,7 +32,7 @@
15
32
 
16
33
  ## 4.1.0 / 2019-08-08
17
34
 
18
- * 4 features
35
+ * 4 features
19
36
  * Add REQUEST_PATH on parse error message (#1831)
20
37
  * You can now easily add custom log formatters with the `log_formatter` config option (#1816)
21
38
  * Puma.stats now provides process start times (#1844)
@@ -29,17 +46,17 @@
29
46
  * SSL read_nonblock no longer blocks (#1857)
30
47
  * Swallow connection errors when sending early hints (#1822)
31
48
  * Backtrace no longer dumped when invalid pumactl commands are run (#1863)
32
-
33
- * 5 other
49
+
50
+ * 5 other
34
51
  * Avoid casting worker_timeout twice (#1838)
35
52
  * Removed a call to private that wasn't doing anything (#1882)
36
53
  * README, Rakefile, docs and test cleanups (#1848, #1847, #1846, #1853, #1859, #1850, #1866, #1870, #1872, #1833, #1888)
37
54
  * Puma.io has proper documentation now (https://puma.io/puma/)
38
55
  * Added the Contributor Covenant CoC
39
-
40
- * 1 known issue
56
+
57
+ * 1 known issue
41
58
  * Some users are still experiencing issues surrounding socket activation and Unix sockets (#1842)
42
-
59
+
43
60
  ## 4.0.1 / 2019-07-11
44
61
 
45
62
  * 2 bugfixes
@@ -61,7 +78,7 @@
61
78
  * Reactor now uses nio4r instead of `select` (#1728)
62
79
  * Add status to pumactl with pidfile (#1824)
63
80
 
64
- * 9 bugfixes
81
+ * 10 bugfixes
65
82
  * Do not accept new requests on shutdown (#1685, #1808)
66
83
  * Fix 3 corner cases when request body is chunked (#1508)
67
84
  * Change pid existence check's condition branches (#1650)
@@ -71,6 +88,13 @@
71
88
  * Fix Java 8 support (#1773)
72
89
  * Fix error `uninitialized constant Puma::Cluster` (#1731)
73
90
  * Fix `not_token` being able to be set to true (#1803)
91
+ * Fix "Hang on SIGTERM with ruby 2.6 in clustered mode" ([PR #1741], [#1674], [#1720], [#1730], [#1755])
92
+
93
+ [PR #1741]: https://github.com/puma/puma/pull/1741
94
+ [#1674]: https://github.com/puma/puma/issues/1674
95
+ [#1720]: https://github.com/puma/puma/issues/1720
96
+ [#1730]: https://github.com/puma/puma/issues/1730
97
+ [#1755]: https://github.com/puma/puma/issues/1755
74
98
 
75
99
  ## 3.12.1 / 2019-03-19
76
100
 
data/README.md CHANGED
@@ -5,8 +5,8 @@
5
5
  # Puma: A Ruby Web Server Built For Concurrency
6
6
 
7
7
  [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/puma/puma?utm\_source=badge&utm\_medium=badge&utm\_campaign=pr-badge)
8
- [![Travis Build Status](https://secure.travis-ci.org/puma/puma.svg)](https://travis-ci.org/puma/puma)
9
- [![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/0xnxc7a26u9b2bub/branch/master?svg=true)](https://ci.appveyor.com/project/puma/puma/branch/master)
8
+ [![Travis Build Status](https://travis-ci.org/puma/puma.svg?branch=master)](https://travis-ci.org/puma/puma)
9
+
10
10
  [![Code Climate](https://codeclimate.com/github/puma/puma.svg)](https://codeclimate.com/github/puma/puma)
11
11
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=puma&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=puma&package-manager=bundler&version-scheme=semver)
12
12
 
@@ -16,7 +16,7 @@ Puma is a **simple, fast, multi-threaded, and highly concurrent HTTP 1.1 server
16
16
 
17
17
  Puma processes requests using a C-optimized Ragel extension (inherited from Mongrel) that provides fast, accurate HTTP 1.1 protocol parsing in a portable way. Puma then serves the request using a thread pool. Each request is served in a separate thread, so truly concurrent Ruby implementations (JRuby, Rubinius) will use all available CPU cores.
18
18
 
19
- Puma was designed to be the go-to server for [Rubinius](https://rubini.us), but also works well with JRuby and MRI.
19
+ Puma was designed to be the go-to server for [Rubinius](https://rubinius.com), but also works well with JRuby and MRI.
20
20
 
21
21
  On MRI, there is a Global VM Lock (GVL) that ensures only one thread can run Ruby code at a time. But if you're doing a lot of blocking IO (such as HTTP calls to external APIs like Twitter), Puma still improves MRI's throughput by allowing IO waiting to be done in parallel.
22
22
 
@@ -118,17 +118,6 @@ This code can be used to setup the process before booting the application, allow
118
118
  you to do some Puma-specific things that you don't want to embed in your application.
119
119
  For instance, you could fire a log notification that a worker booted or send something to statsd. This can be called multiple times.
120
120
 
121
- If you're preloading your application and using ActiveRecord, it's recommended that you setup your connection pool here:
122
-
123
- ```ruby
124
- # config/puma.rb
125
- on_worker_boot do
126
- ActiveSupport.on_load(:active_record) do
127
- ActiveRecord::Base.establish_connection
128
- end
129
- end
130
- ```
131
-
132
121
  `before_fork` specifies a block to be run before workers are forked:
133
122
 
134
123
  ```ruby
@@ -297,10 +286,10 @@ $ bundle install
297
286
  $ bundle exec rake
298
287
  ```
299
288
 
300
- To run a single test file, use the `TEST` environment variable:
289
+ To run a single test file, run only that file:
301
290
 
302
291
  ```bash
303
- $ TEST=test/test_binder.rb bundle exec rake test
292
+ $ ruby -Ilib test/test_integration.rb
304
293
  ```
305
294
 
306
295
  Or use [`m`](https://github.com/qrush/m):
@@ -38,7 +38,7 @@ static void snake_upcase_char(char *c)
38
38
 
39
39
  #line 40 "ext/puma_http11/http11_parser.c"
40
40
  static const int puma_parser_start = 1;
41
- static const int puma_parser_first_final = 47;
41
+ static const int puma_parser_first_final = 46;
42
42
  static const int puma_parser_error = 0;
43
43
 
44
44
  static const int puma_parser_en_main = 1;
@@ -117,17 +117,17 @@ case 2:
117
117
  #line 118 "ext/puma_http11/http11_parser.c"
118
118
  switch( (*p) ) {
119
119
  case 32: goto tr2;
120
- case 36: goto st28;
121
- case 95: goto st28;
120
+ case 36: goto st27;
121
+ case 95: goto st27;
122
122
  }
123
123
  if ( (*p) < 48 ) {
124
124
  if ( 45 <= (*p) && (*p) <= 46 )
125
- goto st28;
125
+ goto st27;
126
126
  } else if ( (*p) > 57 ) {
127
127
  if ( 65 <= (*p) && (*p) <= 90 )
128
- goto st28;
128
+ goto st27;
129
129
  } else
130
- goto st28;
130
+ goto st27;
131
131
  goto st0;
132
132
  tr2:
133
133
  #line 48 "ext/puma_http11/http11_parser.rl"
@@ -199,7 +199,7 @@ tr37:
199
199
  parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
200
200
  }
201
201
  goto st5;
202
- tr44:
202
+ tr41:
203
203
  #line 58 "ext/puma_http11/http11_parser.rl"
204
204
  { MARK(query_start, p); }
205
205
  #line 59 "ext/puma_http11/http11_parser.rl"
@@ -211,7 +211,7 @@ tr44:
211
211
  parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
212
212
  }
213
213
  goto st5;
214
- tr47:
214
+ tr44:
215
215
  #line 59 "ext/puma_http11/http11_parser.rl"
216
216
  {
217
217
  parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
@@ -362,13 +362,13 @@ tr22:
362
362
  {
363
363
  parser->body_start = p - buffer + 1;
364
364
  parser->header_done(parser, p + 1, pe - p - 1);
365
- {p++; cs = 47; goto _out;}
365
+ {p++; cs = 46; goto _out;}
366
366
  }
367
- goto st47;
368
- st47:
367
+ goto st46;
368
+ st46:
369
369
  if ( ++p == pe )
370
- goto _test_eof47;
371
- case 47:
370
+ goto _test_eof46;
371
+ case 46:
372
372
  #line 373 "ext/puma_http11/http11_parser.c"
373
373
  goto st0;
374
374
  tr21:
@@ -458,7 +458,7 @@ tr38:
458
458
  parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
459
459
  }
460
460
  goto st20;
461
- tr45:
461
+ tr42:
462
462
  #line 58 "ext/puma_http11/http11_parser.rl"
463
463
  { MARK(query_start, p); }
464
464
  #line 59 "ext/puma_http11/http11_parser.rl"
@@ -470,7 +470,7 @@ tr45:
470
470
  parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
471
471
  }
472
472
  goto st20;
473
- tr48:
473
+ tr45:
474
474
  #line 59 "ext/puma_http11/http11_parser.rl"
475
475
  {
476
476
  parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
@@ -576,10 +576,9 @@ case 24:
576
576
  case 32: goto tr37;
577
577
  case 34: goto st0;
578
578
  case 35: goto tr38;
579
- case 59: goto tr39;
580
579
  case 60: goto st0;
581
580
  case 62: goto st0;
582
- case 63: goto tr40;
581
+ case 63: goto tr39;
583
582
  case 127: goto st0;
584
583
  }
585
584
  if ( 0 <= (*p) && (*p) <= 31 )
@@ -595,30 +594,27 @@ st25:
595
594
  if ( ++p == pe )
596
595
  goto _test_eof25;
597
596
  case 25:
598
- #line 599 "ext/puma_http11/http11_parser.c"
597
+ #line 598 "ext/puma_http11/http11_parser.c"
599
598
  switch( (*p) ) {
600
- case 32: goto tr8;
599
+ case 32: goto tr41;
601
600
  case 34: goto st0;
602
- case 35: goto tr9;
601
+ case 35: goto tr42;
603
602
  case 60: goto st0;
604
603
  case 62: goto st0;
605
- case 63: goto st26;
606
604
  case 127: goto st0;
607
605
  }
608
606
  if ( 0 <= (*p) && (*p) <= 31 )
609
607
  goto st0;
610
- goto st25;
608
+ goto tr40;
611
609
  tr40:
612
- #line 67 "ext/puma_http11/http11_parser.rl"
613
- {
614
- parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
615
- }
610
+ #line 58 "ext/puma_http11/http11_parser.rl"
611
+ { MARK(query_start, p); }
616
612
  goto st26;
617
613
  st26:
618
614
  if ( ++p == pe )
619
615
  goto _test_eof26;
620
616
  case 26:
621
- #line 622 "ext/puma_http11/http11_parser.c"
617
+ #line 618 "ext/puma_http11/http11_parser.c"
622
618
  switch( (*p) ) {
623
619
  case 32: goto tr44;
624
620
  case 34: goto st0;
@@ -629,27 +625,25 @@ case 26:
629
625
  }
630
626
  if ( 0 <= (*p) && (*p) <= 31 )
631
627
  goto st0;
632
- goto tr43;
633
- tr43:
634
- #line 58 "ext/puma_http11/http11_parser.rl"
635
- { MARK(query_start, p); }
636
- goto st27;
628
+ goto st26;
637
629
  st27:
638
630
  if ( ++p == pe )
639
631
  goto _test_eof27;
640
632
  case 27:
641
- #line 642 "ext/puma_http11/http11_parser.c"
642
633
  switch( (*p) ) {
643
- case 32: goto tr47;
644
- case 34: goto st0;
645
- case 35: goto tr48;
646
- case 60: goto st0;
647
- case 62: goto st0;
648
- case 127: goto st0;
634
+ case 32: goto tr2;
635
+ case 36: goto st28;
636
+ case 95: goto st28;
649
637
  }
650
- if ( 0 <= (*p) && (*p) <= 31 )
651
- goto st0;
652
- goto st27;
638
+ if ( (*p) < 48 ) {
639
+ if ( 45 <= (*p) && (*p) <= 46 )
640
+ goto st28;
641
+ } else if ( (*p) > 57 ) {
642
+ if ( 65 <= (*p) && (*p) <= 90 )
643
+ goto st28;
644
+ } else
645
+ goto st28;
646
+ goto st0;
653
647
  st28:
654
648
  if ( ++p == pe )
655
649
  goto _test_eof28;
@@ -960,24 +954,6 @@ st45:
960
954
  if ( ++p == pe )
961
955
  goto _test_eof45;
962
956
  case 45:
963
- switch( (*p) ) {
964
- case 32: goto tr2;
965
- case 36: goto st46;
966
- case 95: goto st46;
967
- }
968
- if ( (*p) < 48 ) {
969
- if ( 45 <= (*p) && (*p) <= 46 )
970
- goto st46;
971
- } else if ( (*p) > 57 ) {
972
- if ( 65 <= (*p) && (*p) <= 90 )
973
- goto st46;
974
- } else
975
- goto st46;
976
- goto st0;
977
- st46:
978
- if ( ++p == pe )
979
- goto _test_eof46;
980
- case 46:
981
957
  if ( (*p) == 32 )
982
958
  goto tr2;
983
959
  goto st0;
@@ -997,7 +973,7 @@ case 46:
997
973
  _test_eof14: cs = 14; goto _test_eof;
998
974
  _test_eof15: cs = 15; goto _test_eof;
999
975
  _test_eof16: cs = 16; goto _test_eof;
1000
- _test_eof47: cs = 47; goto _test_eof;
976
+ _test_eof46: cs = 46; goto _test_eof;
1001
977
  _test_eof17: cs = 17; goto _test_eof;
1002
978
  _test_eof18: cs = 18; goto _test_eof;
1003
979
  _test_eof19: cs = 19; goto _test_eof;
@@ -1027,7 +1003,6 @@ case 46:
1027
1003
  _test_eof43: cs = 43; goto _test_eof;
1028
1004
  _test_eof44: cs = 44; goto _test_eof;
1029
1005
  _test_eof45: cs = 45; goto _test_eof;
1030
- _test_eof46: cs = 46; goto _test_eof;
1031
1006
 
1032
1007
  _test_eof: {}
1033
1008
  _out: {}
@@ -1,5 +1,5 @@
1
1
  %%{
2
-
2
+
3
3
  machine puma_parser_common;
4
4
 
5
5
  #### HTTP PROTOCOL GRAMMAR
@@ -16,7 +16,7 @@
16
16
  unreserved = (alpha | digit | safe | extra | national);
17
17
  escape = ("%" xdigit xdigit);
18
18
  uchar = (unreserved | escape | "%");
19
- pchar = (uchar | ":" | "@" | "&" | "=" | "+");
19
+ pchar = (uchar | ":" | "@" | "&" | "=" | "+" | ";");
20
20
  tspecials = ("(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\\" | "\"" | "/" | "[" | "]" | "?" | "=" | "{" | "}" | " " | "\t");
21
21
 
22
22
  # elements
@@ -30,7 +30,7 @@
30
30
  query = ( uchar | reserved )* %query_string ;
31
31
  param = ( pchar | "/" )* ;
32
32
  params = ( param ( ";" param )* ) ;
33
- rel_path = ( path? %request_path (";" params)? ) ("?" %start_query query)?;
33
+ rel_path = ( path? %request_path ) ("?" %start_query query)?;
34
34
  absolute_path = ( "/"+ rel_path );
35
35
 
36
36
  Request_URI = ( "*" | absolute_uri | absolute_path ) >mark %request_uri;
@@ -22,4 +22,10 @@ module Puma
22
22
  def self.stats
23
23
  @get_stats.stats
24
24
  end
25
+
26
+ # Thread name is new in Ruby 2.3
27
+ def self.set_thread_name(name)
28
+ return unless Thread.current.respond_to?(:name=)
29
+ Thread.current.name = "puma #{name}"
30
+ end
25
31
  end
@@ -7,26 +7,11 @@ module Puma
7
7
  # Check out {#call}'s source code to see what actions this web application
8
8
  # can respond to.
9
9
  class Status
10
- def initialize(cli)
11
- @cli = cli
12
- @auth_token = nil
13
- end
14
10
  OK_STATUS = '{ "status": "ok" }'.freeze
15
11
 
16
- attr_accessor :auth_token
17
-
18
- def authenticate(env)
19
- return true unless @auth_token
20
- env['QUERY_STRING'].to_s.split(/&;/).include?("token=#{@auth_token}")
21
- end
22
-
23
- def rack_response(status, body, content_type='application/json')
24
- headers = {
25
- 'Content-Type' => content_type,
26
- 'Content-Length' => body.bytesize.to_s
27
- }
28
-
29
- [status, headers, [body]]
12
+ def initialize(cli, token = nil)
13
+ @cli = cli
14
+ @auth_token = token
30
15
  end
31
16
 
32
17
  def call(env)
@@ -37,43 +22,59 @@ module Puma
37
22
  case env['PATH_INFO']
38
23
  when /\/stop$/
39
24
  @cli.stop
40
- return rack_response(200, OK_STATUS)
25
+ rack_response(200, OK_STATUS)
41
26
 
42
27
  when /\/halt$/
43
28
  @cli.halt
44
- return rack_response(200, OK_STATUS)
29
+ rack_response(200, OK_STATUS)
45
30
 
46
31
  when /\/restart$/
47
32
  @cli.restart
48
- return rack_response(200, OK_STATUS)
33
+ rack_response(200, OK_STATUS)
49
34
 
50
35
  when /\/phased-restart$/
51
36
  if !@cli.phased_restart
52
- return rack_response(404, '{ "error": "phased restart not available" }')
37
+ rack_response(404, '{ "error": "phased restart not available" }')
53
38
  else
54
- return rack_response(200, OK_STATUS)
39
+ rack_response(200, OK_STATUS)
55
40
  end
56
41
 
57
42
  when /\/reload-worker-directory$/
58
43
  if !@cli.send(:reload_worker_directory)
59
- return rack_response(404, '{ "error": "reload_worker_directory not available" }')
44
+ rack_response(404, '{ "error": "reload_worker_directory not available" }')
60
45
  else
61
- return rack_response(200, OK_STATUS)
46
+ rack_response(200, OK_STATUS)
62
47
  end
63
48
 
64
49
  when /\/gc$/
65
50
  GC.start
66
- return rack_response(200, OK_STATUS)
51
+ rack_response(200, OK_STATUS)
67
52
 
68
53
  when /\/gc-stats$/
69
- return rack_response(200, GC.stat.to_json)
54
+ rack_response(200, GC.stat.to_json)
70
55
 
71
56
  when /\/stats$/
72
- return rack_response(200, @cli.stats)
57
+ rack_response(200, @cli.stats)
73
58
  else
74
59
  rack_response 404, "Unsupported action", 'text/plain'
75
60
  end
76
61
  end
62
+
63
+ private
64
+
65
+ def authenticate(env)
66
+ return true unless @auth_token
67
+ env['QUERY_STRING'].to_s.split(/&;/).include?("token=#{@auth_token}")
68
+ end
69
+
70
+ def rack_response(status, body, content_type='application/json')
71
+ headers = {
72
+ 'Content-Type' => content_type,
73
+ 'Content-Length' => body.bytesize.to_s
74
+ }
75
+
76
+ [status, headers, [body]]
77
+ end
77
78
  end
78
79
  end
79
80
  end