puma 5.0.4-java → 5.1.0-java

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.

@@ -59,7 +59,7 @@ module Puma
59
59
 
60
60
  control.binder.parse [str], self, 'Starting control server'
61
61
 
62
- control.run
62
+ control.run thread_name: 'control'
63
63
  @control = control
64
64
  end
65
65
 
@@ -86,9 +86,16 @@ module Puma
86
86
  max_t = @options[:max_threads]
87
87
 
88
88
  log "Puma starting in #{mode} mode..."
89
- log "* Version #{Puma::Const::PUMA_VERSION} (#{ruby_engine}), codename: #{Puma::Const::CODE_NAME}"
90
- log "* Min threads: #{min_t}, max threads: #{max_t}"
91
- log "* Environment: #{ENV['RACK_ENV']}"
89
+ log "* Puma version: #{Puma::Const::PUMA_VERSION} (#{ruby_engine}) (\"#{Puma::Const::CODE_NAME}\")"
90
+ log "* Min threads: #{min_t}"
91
+ log "* Max threads: #{max_t}"
92
+ log "* Environment: #{ENV['RACK_ENV']}"
93
+
94
+ if mode == "cluster"
95
+ log "* Master PID: #{Process.pid}"
96
+ else
97
+ log "* PID: #{Process.pid}"
98
+ end
92
99
  end
93
100
 
94
101
  def redirected_io?
@@ -90,6 +90,7 @@ module Puma
90
90
  @max_threads = options.fetch :max_threads , (Puma.mri? ? 5 : 16)
91
91
  @persistent_timeout = options.fetch :persistent_timeout, PERSISTENT_TIMEOUT
92
92
  @queue_requests = options.fetch :queue_requests, true
93
+ @max_fast_inline = options.fetch :max_fast_inline, MAX_FAST_INLINE
93
94
 
94
95
  temp = !!(@options[:environment] =~ /\A(development|test)\z/)
95
96
  @leak_stack_on_error = @options[:environment] ? temp : true
@@ -218,7 +219,7 @@ module Puma
218
219
  # up in the background to handle requests. Otherwise requests
219
220
  # are handled synchronously.
220
221
  #
221
- def run(background=true)
222
+ def run(background=true, thread_name: 'server')
222
223
  BasicSocket.do_not_reverse_lookup = true
223
224
 
224
225
  @events.fire :state, :booting
@@ -254,7 +255,7 @@ module Puma
254
255
 
255
256
  if background
256
257
  @thread = Thread.new do
257
- Puma.set_thread_name "server"
258
+ Puma.set_thread_name thread_name
258
259
  handle_servers
259
260
  end
260
261
  return @thread
@@ -442,11 +443,11 @@ module Puma
442
443
 
443
444
  check_for_more_data = @status == :run
444
445
 
445
- if requests >= MAX_FAST_INLINE
446
+ if requests >= @max_fast_inline
446
447
  # This will mean that reset will only try to use the data it already
447
448
  # has buffered and won't try to read more data. What this means is that
448
449
  # every client, independent of their request speed, gets treated like a slow
449
- # one once every MAX_FAST_INLINE requests.
450
+ # one once every max_fast_inline requests.
450
451
  check_for_more_data = false
451
452
  end
452
453
 
@@ -9,9 +9,11 @@ module Puma
9
9
  end
10
10
 
11
11
  def save(path, permission = nil)
12
- File.open(path, "w") do |file|
13
- file.chmod(permission) if permission
14
- file.write(YAML.dump(@options))
12
+ contents =YAML.dump @options
13
+ if permission
14
+ File.write path, contents, mode: 'wb:UTF-8'
15
+ else
16
+ File.write path, contents, mode: 'wb:UTF-8', perm: permission
15
17
  end
16
18
  end
17
19
 
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'sd_notify'
4
+
5
+ module Puma
6
+ class Systemd
7
+ def initialize(events)
8
+ @events = events
9
+ end
10
+
11
+ def hook_events
12
+ @events.on_booted { SdNotify.ready }
13
+ @events.on_stopped { SdNotify.stopping }
14
+ @events.on_restart { SdNotify.reloading }
15
+ end
16
+
17
+ def start_watchdog
18
+ return unless SdNotify.watchdog?
19
+
20
+ ping_f = watchdog_sleep_time
21
+
22
+ log "Pinging systemd watchdog every #{ping_f.round(1)} sec"
23
+ Thread.new do
24
+ loop do
25
+ sleep ping_f
26
+ SdNotify.watchdog
27
+ end
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def watchdog_sleep_time
34
+ usec = Integer(ENV["WATCHDOG_USEC"])
35
+
36
+ sec_f = usec / 1_000_000.0
37
+ # "It is recommended that a daemon sends a keep-alive notification message
38
+ # to the service manager every half of the time returned here."
39
+ sec_f / 2
40
+ end
41
+
42
+ def log(str)
43
+ @events.log str
44
+ end
45
+ end
46
+ end
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: 5.0.4
4
+ version: 5.1.0
5
5
  platform: java
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-27 00:00:00.000000000 Z
11
+ date: 2020-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -43,6 +43,7 @@ files:
43
43
  - bin/puma-wild
44
44
  - bin/pumactl
45
45
  - docs/architecture.md
46
+ - docs/compile_options.md
46
47
  - docs/deployment.md
47
48
  - docs/fork_worker.md
48
49
  - docs/images/puma-connection-flow-no-reactor.png
@@ -89,6 +90,7 @@ files:
89
90
  - lib/puma/events.rb
90
91
  - lib/puma/io_buffer.rb
91
92
  - lib/puma/jruby_restart.rb
93
+ - lib/puma/json.rb
92
94
  - lib/puma/launcher.rb
93
95
  - lib/puma/minissl.rb
94
96
  - lib/puma/minissl/context_builder.rb
@@ -106,6 +108,7 @@ files:
106
108
  - lib/puma/server.rb
107
109
  - lib/puma/single.rb
108
110
  - lib/puma/state_file.rb
111
+ - lib/puma/systemd.rb
109
112
  - lib/puma/thread_pool.rb
110
113
  - lib/puma/util.rb
111
114
  - lib/rack/handler/puma.rb