puma 4.0.1 → 4.2.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.

@@ -18,7 +18,7 @@ module Puma
18
18
  r = @server.running || 0
19
19
  t = @server.pool_capacity || 0
20
20
  m = @server.max_threads || 0
21
- %Q!{ "backlog": #{b}, "running": #{r}, "pool_capacity": #{t}, "max_threads": #{m} }!
21
+ %Q!{ "started_at": "#{@started_at.utc.iso8601}", "backlog": #{b}, "running": #{r}, "pool_capacity": #{t}, "max_threads": #{m} }!
22
22
  end
23
23
 
24
24
  def restart
@@ -87,8 +87,7 @@ module Puma
87
87
  @spawned += 1
88
88
 
89
89
  th = Thread.new(@spawned) do |spawned|
90
- # Thread name is new in Ruby 2.3
91
- Thread.current.name = 'puma %03i' % spawned if Thread.current.respond_to?(:name=)
90
+ Puma.set_thread_name 'threadpool %03i' % spawned
92
91
  todo = @todo
93
92
  block = @block
94
93
  mutex = @mutex
@@ -244,10 +243,12 @@ module Puma
244
243
  end
245
244
  end
246
245
 
247
- class AutoTrim
248
- def initialize(pool, timeout)
246
+ class Automaton
247
+ def initialize(pool, timeout, thread_name, message)
249
248
  @pool = pool
250
249
  @timeout = timeout
250
+ @thread_name = thread_name
251
+ @message = message
251
252
  @running = false
252
253
  end
253
254
 
@@ -255,8 +256,9 @@ module Puma
255
256
  @running = true
256
257
 
257
258
  @thread = Thread.new do
259
+ Puma.set_thread_name @thread_name
258
260
  while @running
259
- @pool.trim
261
+ @pool.public_send(@message)
260
262
  sleep @timeout
261
263
  end
262
264
  end
@@ -269,36 +271,12 @@ module Puma
269
271
  end
270
272
 
271
273
  def auto_trim!(timeout=30)
272
- @auto_trim = AutoTrim.new(self, timeout)
274
+ @auto_trim = Automaton.new(self, timeout, "threadpool trimmer", :trim)
273
275
  @auto_trim.start!
274
276
  end
275
277
 
276
- class Reaper
277
- def initialize(pool, timeout)
278
- @pool = pool
279
- @timeout = timeout
280
- @running = false
281
- end
282
-
283
- def start!
284
- @running = true
285
-
286
- @thread = Thread.new do
287
- while @running
288
- @pool.reap
289
- sleep @timeout
290
- end
291
- end
292
- end
293
-
294
- def stop
295
- @running = false
296
- @thread.wakeup
297
- end
298
- end
299
-
300
278
  def auto_reap!(timeout=5)
301
- @reaper = Reaper.new(self, timeout)
279
+ @reaper = Automaton.new(self, timeout, "threadpool reaper", :reap)
302
280
  @reaper.start!
303
281
  end
304
282
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rack/handler'
2
4
 
3
5
  module Rack
@@ -59,8 +61,6 @@ module Rack
59
61
  conf
60
62
  end
61
63
 
62
-
63
-
64
64
  def self.run(app, options = {})
65
65
  conf = self.config(app, options)
66
66
 
@@ -86,7 +86,7 @@ module Rack
86
86
  "Verbose" => "Don't report each request (default: false)"
87
87
  }
88
88
  end
89
- private
89
+
90
90
  def self.set_host_port_to_config(host, port, config)
91
91
  config.clear_binds! if host || port
92
92
 
@@ -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
@@ -398,7 +398,7 @@ case "$1" in
398
398
  ;;
399
399
  remove)
400
400
  if [ "$#" -lt 2 ]; then
401
- echo "Please, specifiy the app's directory to remove."
401
+ echo "Please, specify the app's directory to remove."
402
402
  exit 1
403
403
  else
404
404
  do_remove $2
@@ -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.0.1
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-11 00:00:00.000000000 Z
11
+ date: 2019-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r
@@ -80,8 +80,6 @@ files:
80
80
  - lib/puma/const.rb
81
81
  - lib/puma/control_cli.rb
82
82
  - lib/puma/convenient.rb
83
- - lib/puma/daemon_ext.rb
84
- - lib/puma/delegation.rb
85
83
  - lib/puma/detect.rb
86
84
  - lib/puma/dsl.rb
87
85
  - lib/puma/events.rb
@@ -104,6 +102,7 @@ files:
104
102
  - lib/puma/thread_pool.rb
105
103
  - lib/puma/util.rb
106
104
  - lib/rack/handler/puma.rb
105
+ - tools/docker/Dockerfile
107
106
  - tools/jungle/README.md
108
107
  - tools/jungle/init.d/README.md
109
108
  - tools/jungle/init.d/puma
@@ -120,6 +119,7 @@ licenses:
120
119
  - BSD-3-Clause
121
120
  metadata:
122
121
  msys2_mingw_dependencies: openssl
122
+ changelog_uri: https://github.com/puma/puma/blob/master/History.md
123
123
  post_install_message:
124
124
  rdoc_options: []
125
125
  require_paths:
@@ -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