puma 4.1.1 → 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.

Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +149 -10
  3. data/LICENSE +23 -20
  4. data/README.md +30 -46
  5. data/docs/architecture.md +3 -3
  6. data/docs/deployment.md +9 -3
  7. data/docs/fork_worker.md +31 -0
  8. data/docs/jungle/README.md +13 -0
  9. data/{tools → docs}/jungle/rc.d/README.md +0 -0
  10. data/{tools → docs}/jungle/rc.d/puma +0 -0
  11. data/{tools → docs}/jungle/rc.d/puma.conf +0 -0
  12. data/{tools → docs}/jungle/upstart/README.md +0 -0
  13. data/{tools → docs}/jungle/upstart/puma-manager.conf +0 -0
  14. data/{tools → docs}/jungle/upstart/puma.conf +0 -0
  15. data/docs/plugins.md +20 -10
  16. data/docs/signals.md +7 -6
  17. data/docs/systemd.md +1 -63
  18. data/ext/puma_http11/PumaHttp11Service.java +2 -4
  19. data/ext/puma_http11/extconf.rb +6 -0
  20. data/ext/puma_http11/http11_parser.c +40 -63
  21. data/ext/puma_http11/http11_parser.java.rl +21 -37
  22. data/ext/puma_http11/http11_parser.rl +3 -1
  23. data/ext/puma_http11/http11_parser_common.rl +3 -3
  24. data/ext/puma_http11/mini_ssl.c +15 -2
  25. data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
  26. data/ext/puma_http11/org/jruby/puma/Http11.java +108 -116
  27. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +91 -106
  28. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +77 -18
  29. data/ext/puma_http11/puma_http11.c +9 -38
  30. data/lib/puma.rb +23 -0
  31. data/lib/puma/app/status.rb +46 -30
  32. data/lib/puma/binder.rb +112 -124
  33. data/lib/puma/cli.rb +11 -15
  34. data/lib/puma/client.rb +250 -209
  35. data/lib/puma/cluster.rb +203 -85
  36. data/lib/puma/commonlogger.rb +2 -2
  37. data/lib/puma/configuration.rb +31 -42
  38. data/lib/puma/const.rb +24 -19
  39. data/lib/puma/control_cli.rb +46 -17
  40. data/lib/puma/detect.rb +17 -0
  41. data/lib/puma/dsl.rb +162 -70
  42. data/lib/puma/error_logger.rb +97 -0
  43. data/lib/puma/events.rb +35 -31
  44. data/lib/puma/io_buffer.rb +9 -2
  45. data/lib/puma/jruby_restart.rb +0 -58
  46. data/lib/puma/launcher.rb +117 -58
  47. data/lib/puma/minissl.rb +60 -18
  48. data/lib/puma/minissl/context_builder.rb +73 -0
  49. data/lib/puma/null_io.rb +1 -1
  50. data/lib/puma/plugin.rb +6 -12
  51. data/lib/puma/rack/builder.rb +0 -4
  52. data/lib/puma/reactor.rb +16 -9
  53. data/lib/puma/runner.rb +11 -32
  54. data/lib/puma/server.rb +173 -193
  55. data/lib/puma/single.rb +7 -64
  56. data/lib/puma/state_file.rb +6 -3
  57. data/lib/puma/thread_pool.rb +104 -81
  58. data/lib/rack/handler/puma.rb +1 -5
  59. data/tools/Dockerfile +16 -0
  60. data/tools/trickletest.rb +0 -1
  61. metadata +23 -24
  62. data/ext/puma_http11/io_buffer.c +0 -155
  63. data/ext/puma_http11/org/jruby/puma/IOBuffer.java +0 -72
  64. data/lib/puma/convenient.rb +0 -25
  65. data/lib/puma/daemon_ext.rb +0 -33
  66. data/lib/puma/delegation.rb +0 -13
  67. data/lib/puma/tcp_logger.rb +0 -41
  68. data/tools/jungle/README.md +0 -19
  69. data/tools/jungle/init.d/README.md +0 -61
  70. data/tools/jungle/init.d/puma +0 -421
  71. data/tools/jungle/init.d/run-puma +0 -18
@@ -30,8 +30,6 @@ module Rack
30
30
  end
31
31
 
32
32
  conf = ::Puma::Configuration.new(options, default_options) do |user_config, file_config, default_config|
33
- user_config.quiet
34
-
35
33
  if options.delete(:Verbose)
36
34
  app = Rack::CommonLogger.new(app, STDOUT)
37
35
  end
@@ -61,9 +59,7 @@ module Rack
61
59
  conf
62
60
  end
63
61
 
64
-
65
-
66
- def self.run(app, options = {})
62
+ def self.run(app, **options)
67
63
  conf = self.config(app, options)
68
64
 
69
65
  events = options.delete(:Silent) ? ::Puma::Events.strings : ::Puma::Events.stdio
@@ -0,0 +1,16 @@
1
+ # Use this Dockerfile to create minimal reproductions of issues
2
+
3
+ FROM ruby:2.6
4
+
5
+ # throw errors if Gemfile has been modified since Gemfile.lock
6
+ RUN bundle config --global frozen 1
7
+
8
+ WORKDIR /usr/src/app
9
+
10
+ COPY . .
11
+ RUN gem install bundler
12
+ RUN bundle install
13
+ RUN bundle exec rake compile
14
+
15
+ EXPOSE 9292
16
+ CMD bundle exec bin/puma test/rackup/hello.ru
@@ -38,7 +38,6 @@ ARGV[1].to_i.times do
38
38
  do_test(st, size)
39
39
  end
40
40
 
41
- t.abort_on_exception = true
42
41
  threads << t
43
42
  end
44
43
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-09 00:00:00.000000000 Z
11
+ date: 2020-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r
@@ -45,9 +45,17 @@ files:
45
45
  - bin/pumactl
46
46
  - docs/architecture.md
47
47
  - docs/deployment.md
48
+ - docs/fork_worker.md
48
49
  - docs/images/puma-connection-flow-no-reactor.png
49
50
  - docs/images/puma-connection-flow.png
50
51
  - docs/images/puma-general-arch.png
52
+ - docs/jungle/README.md
53
+ - docs/jungle/rc.d/README.md
54
+ - docs/jungle/rc.d/puma
55
+ - docs/jungle/rc.d/puma.conf
56
+ - docs/jungle/upstart/README.md
57
+ - docs/jungle/upstart/puma-manager.conf
58
+ - docs/jungle/upstart/puma.conf
51
59
  - docs/nginx.md
52
60
  - docs/plugins.md
53
61
  - docs/restart.md
@@ -61,11 +69,10 @@ files:
61
69
  - ext/puma_http11/http11_parser.java.rl
62
70
  - ext/puma_http11/http11_parser.rl
63
71
  - ext/puma_http11/http11_parser_common.rl
64
- - ext/puma_http11/io_buffer.c
65
72
  - ext/puma_http11/mini_ssl.c
73
+ - ext/puma_http11/no_ssl/PumaHttp11Service.java
66
74
  - ext/puma_http11/org/jruby/puma/Http11.java
67
75
  - ext/puma_http11/org/jruby/puma/Http11Parser.java
68
- - ext/puma_http11/org/jruby/puma/IOBuffer.java
69
76
  - ext/puma_http11/org/jruby/puma/MiniSSL.java
70
77
  - ext/puma_http11/puma_http11.c
71
78
  - lib/puma.rb
@@ -79,16 +86,15 @@ files:
79
86
  - lib/puma/configuration.rb
80
87
  - lib/puma/const.rb
81
88
  - lib/puma/control_cli.rb
82
- - lib/puma/convenient.rb
83
- - lib/puma/daemon_ext.rb
84
- - lib/puma/delegation.rb
85
89
  - lib/puma/detect.rb
86
90
  - lib/puma/dsl.rb
91
+ - lib/puma/error_logger.rb
87
92
  - lib/puma/events.rb
88
93
  - lib/puma/io_buffer.rb
89
94
  - lib/puma/jruby_restart.rb
90
95
  - lib/puma/launcher.rb
91
96
  - lib/puma/minissl.rb
97
+ - lib/puma/minissl/context_builder.rb
92
98
  - lib/puma/null_io.rb
93
99
  - lib/puma/plugin.rb
94
100
  - lib/puma/plugin/tmp_restart.rb
@@ -100,27 +106,20 @@ files:
100
106
  - lib/puma/server.rb
101
107
  - lib/puma/single.rb
102
108
  - lib/puma/state_file.rb
103
- - lib/puma/tcp_logger.rb
104
109
  - lib/puma/thread_pool.rb
105
110
  - lib/puma/util.rb
106
111
  - lib/rack/handler/puma.rb
107
- - tools/jungle/README.md
108
- - tools/jungle/init.d/README.md
109
- - tools/jungle/init.d/puma
110
- - tools/jungle/init.d/run-puma
111
- - tools/jungle/rc.d/README.md
112
- - tools/jungle/rc.d/puma
113
- - tools/jungle/rc.d/puma.conf
114
- - tools/jungle/upstart/README.md
115
- - tools/jungle/upstart/puma-manager.conf
116
- - tools/jungle/upstart/puma.conf
112
+ - tools/Dockerfile
117
113
  - tools/trickletest.rb
118
- homepage: http://puma.io
114
+ homepage: https://puma.io
119
115
  licenses:
120
116
  - BSD-3-Clause
121
117
  metadata:
122
- msys2_mingw_dependencies: openssl
123
- post_install_message:
118
+ bug_tracker_uri: https://github.com/puma/puma/issues
119
+ changelog_uri: https://github.com/puma/puma/blob/master/History.md
120
+ homepage_uri: https://puma.io
121
+ source_code_uri: https://github.com/puma/puma
122
+ post_install_message:
124
123
  rdoc_options: []
125
124
  require_paths:
126
125
  - lib
@@ -135,8 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
134
  - !ruby/object:Gem::Version
136
135
  version: '0'
137
136
  requirements: []
138
- rubygems_version: 3.0.3
139
- signing_key:
137
+ rubygems_version: 3.1.2
138
+ signing_key:
140
139
  specification_version: 4
141
140
  summary: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for
142
141
  Ruby/Rack applications
@@ -1,155 +0,0 @@
1
- #define RSTRING_NOT_MODIFIED 1
2
- #include "ruby.h"
3
-
4
- #include <sys/types.h>
5
-
6
- struct buf_int {
7
- uint8_t* top;
8
- uint8_t* cur;
9
-
10
- size_t size;
11
- };
12
-
13
- #define BUF_DEFAULT_SIZE 4096
14
- #define BUF_TOLERANCE 32
15
-
16
- static void buf_free(struct buf_int* internal) {
17
- xfree(internal->top);
18
- xfree(internal);
19
- }
20
-
21
- static VALUE buf_alloc(VALUE self) {
22
- VALUE buf;
23
- struct buf_int* internal;
24
-
25
- buf = Data_Make_Struct(self, struct buf_int, 0, buf_free, internal);
26
-
27
- internal->size = BUF_DEFAULT_SIZE;
28
- internal->top = ALLOC_N(uint8_t, BUF_DEFAULT_SIZE);
29
- internal->cur = internal->top;
30
-
31
- return buf;
32
- }
33
-
34
- static VALUE buf_append(VALUE self, VALUE str) {
35
- struct buf_int* b;
36
- size_t used, str_len, new_size;
37
-
38
- Data_Get_Struct(self, struct buf_int, b);
39
-
40
- used = b->cur - b->top;
41
-
42
- StringValue(str);
43
- str_len = RSTRING_LEN(str);
44
-
45
- new_size = used + str_len;
46
-
47
- if(new_size > b->size) {
48
- size_t n = b->size + (b->size / 2);
49
- uint8_t* top;
50
- uint8_t* old;
51
-
52
- new_size = (n > new_size ? n : new_size + BUF_TOLERANCE);
53
-
54
- top = ALLOC_N(uint8_t, new_size);
55
- old = b->top;
56
- memcpy(top, old, used);
57
- b->top = top;
58
- b->cur = top + used;
59
- b->size = new_size;
60
- xfree(old);
61
- }
62
-
63
- memcpy(b->cur, RSTRING_PTR(str), str_len);
64
- b->cur += str_len;
65
-
66
- return self;
67
- }
68
-
69
- static VALUE buf_append2(int argc, VALUE* argv, VALUE self) {
70
- struct buf_int* b;
71
- size_t used, new_size;
72
- int i;
73
- VALUE str;
74
-
75
- Data_Get_Struct(self, struct buf_int, b);
76
-
77
- used = b->cur - b->top;
78
- new_size = used;
79
-
80
- for(i = 0; i < argc; i++) {
81
- StringValue(argv[i]);
82
-
83
- str = argv[i];
84
-
85
- new_size += RSTRING_LEN(str);
86
- }
87
-
88
- if(new_size > b->size) {
89
- size_t n = b->size + (b->size / 2);
90
- uint8_t* top;
91
- uint8_t* old;
92
-
93
- new_size = (n > new_size ? n : new_size + BUF_TOLERANCE);
94
-
95
- top = ALLOC_N(uint8_t, new_size);
96
- old = b->top;
97
- memcpy(top, old, used);
98
- b->top = top;
99
- b->cur = top + used;
100
- b->size = new_size;
101
- xfree(old);
102
- }
103
-
104
- for(i = 0; i < argc; i++) {
105
- long str_len;
106
- str = argv[i];
107
- str_len = RSTRING_LEN(str);
108
- memcpy(b->cur, RSTRING_PTR(str), str_len);
109
- b->cur += str_len;
110
- }
111
-
112
- return self;
113
- }
114
-
115
- static VALUE buf_to_str(VALUE self) {
116
- struct buf_int* b;
117
- Data_Get_Struct(self, struct buf_int, b);
118
-
119
- return rb_str_new((const char*)(b->top), b->cur - b->top);
120
- }
121
-
122
- static VALUE buf_used(VALUE self) {
123
- struct buf_int* b;
124
- Data_Get_Struct(self, struct buf_int, b);
125
-
126
- return INT2FIX(b->cur - b->top);
127
- }
128
-
129
- static VALUE buf_capa(VALUE self) {
130
- struct buf_int* b;
131
- Data_Get_Struct(self, struct buf_int, b);
132
-
133
- return INT2FIX(b->size);
134
- }
135
-
136
- static VALUE buf_reset(VALUE self) {
137
- struct buf_int* b;
138
- Data_Get_Struct(self, struct buf_int, b);
139
-
140
- b->cur = b->top;
141
- return self;
142
- }
143
-
144
- void Init_io_buffer(VALUE puma) {
145
- VALUE buf = rb_define_class_under(puma, "IOBuffer", rb_cObject);
146
-
147
- rb_define_alloc_func(buf, buf_alloc);
148
- rb_define_method(buf, "<<", buf_append, 1);
149
- rb_define_method(buf, "append", buf_append2, -1);
150
- rb_define_method(buf, "to_str", buf_to_str, 0);
151
- rb_define_method(buf, "to_s", buf_to_str, 0);
152
- rb_define_method(buf, "used", buf_used, 0);
153
- rb_define_method(buf, "capacity", buf_capa, 0);
154
- rb_define_method(buf, "reset", buf_reset, 0);
155
- }
@@ -1,72 +0,0 @@
1
- package org.jruby.puma;
2
-
3
- import org.jruby.*;
4
- import org.jruby.anno.JRubyMethod;
5
- import org.jruby.runtime.ObjectAllocator;
6
- import org.jruby.runtime.ThreadContext;
7
- import org.jruby.runtime.builtin.IRubyObject;
8
- import org.jruby.util.ByteList;
9
-
10
- /**
11
- * @author kares
12
- */
13
- public class IOBuffer extends RubyObject {
14
-
15
- private static final ObjectAllocator ALLOCATOR = new ObjectAllocator() {
16
- public IRubyObject allocate(Ruby runtime, RubyClass klass) {
17
- return new IOBuffer(runtime, klass);
18
- }
19
- };
20
-
21
- public static void createIOBuffer(Ruby runtime) {
22
- RubyModule mPuma = runtime.defineModule("Puma");
23
- RubyClass cIOBuffer = mPuma.defineClassUnder("IOBuffer", runtime.getObject(), ALLOCATOR);
24
- cIOBuffer.defineAnnotatedMethods(IOBuffer.class);
25
- }
26
-
27
- private static final int DEFAULT_SIZE = 4096;
28
-
29
- final ByteList buffer = new ByteList(DEFAULT_SIZE);
30
-
31
- IOBuffer(Ruby runtime, RubyClass klass) {
32
- super(runtime, klass);
33
- }
34
-
35
- @JRubyMethod
36
- public RubyInteger used(ThreadContext context) {
37
- return context.runtime.newFixnum(buffer.getRealSize());
38
- }
39
-
40
- @JRubyMethod
41
- public RubyInteger capacity(ThreadContext context) {
42
- return context.runtime.newFixnum(buffer.unsafeBytes().length);
43
- }
44
-
45
- @JRubyMethod
46
- public IRubyObject reset() {
47
- buffer.setRealSize(0);
48
- return this;
49
- }
50
-
51
- @JRubyMethod(name = { "to_s", "to_str" })
52
- public RubyString to_s(ThreadContext context) {
53
- return RubyString.newStringShared(context.runtime, buffer.unsafeBytes(), 0, buffer.getRealSize());
54
- }
55
-
56
- @JRubyMethod(name = "<<")
57
- public IRubyObject add(IRubyObject str) {
58
- addImpl(str.convertToString());
59
- return this;
60
- }
61
-
62
- @JRubyMethod(rest = true)
63
- public IRubyObject append(IRubyObject[] strs) {
64
- for (IRubyObject str : strs) addImpl(str.convertToString());
65
- return this;
66
- }
67
-
68
- private void addImpl(RubyString str) {
69
- buffer.append(str.getByteList());
70
- }
71
-
72
- }
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'puma/launcher'
4
- require 'puma/configuration'
5
-
6
- module Puma
7
- def self.run(opts={})
8
- cfg = Puma::Configuration.new do |user_config|
9
- if port = opts[:port]
10
- user_config.port port
11
- end
12
-
13
- user_config.quiet
14
-
15
- yield c
16
- end
17
-
18
- cfg.clamp
19
-
20
- events = Puma::Events.null
21
-
22
- launcher = Puma::Launcher.new cfg, :events => events
23
- launcher.run
24
- end
25
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Process
4
-
5
- # This overrides the default version because it is broken if it
6
- # exists.
7
-
8
- if respond_to? :daemon
9
- class << self
10
- remove_method :daemon
11
- end
12
- end
13
-
14
- def self.daemon(nochdir=false, noclose=false)
15
- exit if fork # Parent exits, child continues.
16
-
17
- Process.setsid # Become session leader.
18
-
19
- exit if fork # Zap session leader. See [1].
20
-
21
- Dir.chdir "/" unless nochdir # Release old working directory.
22
-
23
- if !noclose
24
- STDIN.reopen File.open("/dev/null", "r")
25
-
26
- null_out = File.open "/dev/null", "w"
27
- STDOUT.reopen null_out
28
- STDERR.reopen null_out
29
- end
30
-
31
- 0
32
- end
33
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Puma
4
- module Delegation
5
- def forward(what, who)
6
- module_eval <<-CODE
7
- def #{what}(*args, &block)
8
- #{who}.#{what}(*args, &block)
9
- end
10
- CODE
11
- end
12
- end
13
- end