puma 5.0.0.beta2-java → 5.0.4-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.
- checksums.yaml +4 -4
- data/History.md +1194 -570
- data/README.md +12 -5
- data/bin/puma-wild +3 -9
- data/docs/deployment.md +5 -6
- data/docs/jungle/README.md +0 -4
- data/docs/jungle/rc.d/puma +2 -2
- data/docs/nginx.md +1 -1
- data/docs/restart.md +46 -23
- data/docs/signals.md +3 -3
- data/docs/systemd.md +1 -1
- data/ext/puma_http11/ext_help.h +1 -1
- data/ext/puma_http11/mini_ssl.c +42 -37
- data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +40 -12
- data/ext/puma_http11/puma_http11.c +21 -10
- data/lib/puma.rb +15 -0
- data/lib/puma/app/status.rb +44 -43
- data/lib/puma/binder.rb +35 -8
- data/lib/puma/client.rb +32 -73
- data/lib/puma/cluster.rb +32 -191
- data/lib/puma/cluster/worker.rb +170 -0
- data/lib/puma/cluster/worker_handle.rb +83 -0
- data/lib/puma/configuration.rb +9 -7
- data/lib/puma/const.rb +2 -1
- data/lib/puma/control_cli.rb +2 -0
- data/lib/puma/detect.rb +9 -0
- data/lib/puma/dsl.rb +74 -36
- data/lib/puma/error_logger.rb +3 -2
- data/lib/puma/events.rb +7 -3
- data/lib/puma/launcher.rb +15 -8
- data/lib/puma/minissl.rb +28 -15
- data/lib/puma/minissl/context_builder.rb +0 -3
- data/lib/puma/puma_http11.jar +0 -0
- data/lib/puma/queue_close.rb +26 -0
- data/lib/puma/reactor.rb +77 -373
- data/lib/puma/request.rb +438 -0
- data/lib/puma/runner.rb +6 -18
- data/lib/puma/server.rb +192 -509
- data/lib/puma/single.rb +3 -2
- data/lib/puma/thread_pool.rb +27 -3
- data/lib/puma/util.rb +12 -0
- metadata +9 -8
- data/docs/jungle/upstart/README.md +0 -61
- data/docs/jungle/upstart/puma-manager.conf +0 -31
- data/docs/jungle/upstart/puma.conf +0 -69
- data/lib/puma/accept_nonblock.rb +0 -29
@@ -0,0 +1,170 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Puma
|
4
|
+
class Cluster < Puma::Runner
|
5
|
+
# This class is instantiated by the `Puma::Cluster` and represents a single
|
6
|
+
# worker process.
|
7
|
+
#
|
8
|
+
# At the core of this class is running an instance of `Puma::Server` which
|
9
|
+
# gets created via the `start_server` method from the `Puma::Runner` class
|
10
|
+
# that this inherits from.
|
11
|
+
class Worker < Puma::Runner
|
12
|
+
attr_reader :index, :master
|
13
|
+
|
14
|
+
def initialize(index:, master:, launcher:, pipes:, server: nil)
|
15
|
+
super launcher, launcher.events
|
16
|
+
|
17
|
+
@index = index
|
18
|
+
@master = master
|
19
|
+
@launcher = launcher
|
20
|
+
@options = launcher.options
|
21
|
+
@check_pipe = pipes[:check_pipe]
|
22
|
+
@worker_write = pipes[:worker_write]
|
23
|
+
@fork_pipe = pipes[:fork_pipe]
|
24
|
+
@wakeup = pipes[:wakeup]
|
25
|
+
@server = server
|
26
|
+
end
|
27
|
+
|
28
|
+
def run
|
29
|
+
title = "puma: cluster worker #{index}: #{master}"
|
30
|
+
title += " [#{@options[:tag]}]" if @options[:tag] && !@options[:tag].empty?
|
31
|
+
$0 = title
|
32
|
+
|
33
|
+
Signal.trap "SIGINT", "IGNORE"
|
34
|
+
Signal.trap "SIGCHLD", "DEFAULT"
|
35
|
+
|
36
|
+
Thread.new do
|
37
|
+
Puma.set_thread_name "worker check pipe"
|
38
|
+
IO.select [@check_pipe]
|
39
|
+
log "! Detected parent died, dying"
|
40
|
+
exit! 1
|
41
|
+
end
|
42
|
+
|
43
|
+
# If we're not running under a Bundler context, then
|
44
|
+
# report the info about the context we will be using
|
45
|
+
if !ENV['BUNDLE_GEMFILE']
|
46
|
+
if File.exist?("Gemfile")
|
47
|
+
log "+ Gemfile in context: #{File.expand_path("Gemfile")}"
|
48
|
+
elsif File.exist?("gems.rb")
|
49
|
+
log "+ Gemfile in context: #{File.expand_path("gems.rb")}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Invoke any worker boot hooks so they can get
|
54
|
+
# things in shape before booting the app.
|
55
|
+
@launcher.config.run_hooks :before_worker_boot, index, @launcher.events
|
56
|
+
|
57
|
+
server = @server ||= start_server
|
58
|
+
restart_server = Queue.new << true << false
|
59
|
+
|
60
|
+
fork_worker = @options[:fork_worker] && index == 0
|
61
|
+
|
62
|
+
if fork_worker
|
63
|
+
restart_server.clear
|
64
|
+
worker_pids = []
|
65
|
+
Signal.trap "SIGCHLD" do
|
66
|
+
wakeup! if worker_pids.reject! do |p|
|
67
|
+
Process.wait(p, Process::WNOHANG) rescue true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
Thread.new do
|
72
|
+
Puma.set_thread_name "worker fork pipe"
|
73
|
+
while (idx = @fork_pipe.gets)
|
74
|
+
idx = idx.to_i
|
75
|
+
if idx == -1 # stop server
|
76
|
+
if restart_server.length > 0
|
77
|
+
restart_server.clear
|
78
|
+
server.begin_restart(true)
|
79
|
+
@launcher.config.run_hooks :before_refork, nil, @launcher.events
|
80
|
+
Puma::Util.nakayoshi_gc @events if @options[:nakayoshi_fork]
|
81
|
+
end
|
82
|
+
elsif idx == 0 # restart server
|
83
|
+
restart_server << true << false
|
84
|
+
else # fork worker
|
85
|
+
worker_pids << pid = spawn_worker(idx)
|
86
|
+
@worker_write << "f#{pid}:#{idx}\n" rescue nil
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
Signal.trap "SIGTERM" do
|
93
|
+
@worker_write << "e#{Process.pid}\n" rescue nil
|
94
|
+
restart_server.clear
|
95
|
+
server.stop
|
96
|
+
restart_server << false
|
97
|
+
end
|
98
|
+
|
99
|
+
begin
|
100
|
+
@worker_write << "b#{Process.pid}:#{index}\n"
|
101
|
+
rescue SystemCallError, IOError
|
102
|
+
Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue
|
103
|
+
STDERR.puts "Master seems to have exited, exiting."
|
104
|
+
return
|
105
|
+
end
|
106
|
+
|
107
|
+
while restart_server.pop
|
108
|
+
server_thread = server.run
|
109
|
+
stat_thread ||= Thread.new(@worker_write) do |io|
|
110
|
+
Puma.set_thread_name "stat payload"
|
111
|
+
|
112
|
+
while true
|
113
|
+
begin
|
114
|
+
require 'json'
|
115
|
+
io << "p#{Process.pid}#{server.stats.to_json}\n"
|
116
|
+
rescue IOError
|
117
|
+
Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue
|
118
|
+
break
|
119
|
+
end
|
120
|
+
sleep Const::WORKER_CHECK_INTERVAL
|
121
|
+
end
|
122
|
+
end
|
123
|
+
server_thread.join
|
124
|
+
end
|
125
|
+
|
126
|
+
# Invoke any worker shutdown hooks so they can prevent the worker
|
127
|
+
# exiting until any background operations are completed
|
128
|
+
@launcher.config.run_hooks :before_worker_shutdown, index, @launcher.events
|
129
|
+
ensure
|
130
|
+
@worker_write << "t#{Process.pid}\n" rescue nil
|
131
|
+
@worker_write.close
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def spawn_worker(idx)
|
137
|
+
@launcher.config.run_hooks :before_worker_fork, idx, @launcher.events
|
138
|
+
|
139
|
+
pid = fork do
|
140
|
+
new_worker = Worker.new index: idx,
|
141
|
+
master: master,
|
142
|
+
launcher: @launcher,
|
143
|
+
pipes: { check_pipe: @check_pipe,
|
144
|
+
worker_write: @worker_write },
|
145
|
+
server: @server
|
146
|
+
new_worker.run
|
147
|
+
end
|
148
|
+
|
149
|
+
if !pid
|
150
|
+
log "! Complete inability to spawn new workers detected"
|
151
|
+
log "! Seppuku is the only choice."
|
152
|
+
exit! 1
|
153
|
+
end
|
154
|
+
|
155
|
+
@launcher.config.run_hooks :after_worker_fork, idx, @launcher.events
|
156
|
+
pid
|
157
|
+
end
|
158
|
+
|
159
|
+
def wakeup!
|
160
|
+
return unless @wakeup
|
161
|
+
|
162
|
+
begin
|
163
|
+
@wakeup.write "!" unless @wakeup.closed?
|
164
|
+
rescue SystemCallError, IOError
|
165
|
+
Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Puma
|
4
|
+
class Cluster < Runner
|
5
|
+
# This class represents a worker process from the perspective of the puma
|
6
|
+
# master process. It contains information about the process and its health
|
7
|
+
# and it exposes methods to control the process via IPC. It does not
|
8
|
+
# include the actual logic executed by the worker process itself. For that,
|
9
|
+
# see Puma::Cluster::Worker.
|
10
|
+
class WorkerHandle
|
11
|
+
def initialize(idx, pid, phase, options)
|
12
|
+
@index = idx
|
13
|
+
@pid = pid
|
14
|
+
@phase = phase
|
15
|
+
@stage = :started
|
16
|
+
@signal = "TERM"
|
17
|
+
@options = options
|
18
|
+
@first_term_sent = nil
|
19
|
+
@started_at = Time.now
|
20
|
+
@last_checkin = Time.now
|
21
|
+
@last_status = {}
|
22
|
+
@term = false
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_reader :index, :pid, :phase, :signal, :last_checkin, :last_status, :started_at
|
26
|
+
|
27
|
+
# @version 5.0.0
|
28
|
+
attr_writer :pid, :phase
|
29
|
+
|
30
|
+
def booted?
|
31
|
+
@stage == :booted
|
32
|
+
end
|
33
|
+
|
34
|
+
def boot!
|
35
|
+
@last_checkin = Time.now
|
36
|
+
@stage = :booted
|
37
|
+
end
|
38
|
+
|
39
|
+
def term?
|
40
|
+
@term
|
41
|
+
end
|
42
|
+
|
43
|
+
def ping!(status)
|
44
|
+
@last_checkin = Time.now
|
45
|
+
require 'json'
|
46
|
+
@last_status = JSON.parse(status, symbolize_names: true)
|
47
|
+
end
|
48
|
+
|
49
|
+
# @see Puma::Cluster#check_workers
|
50
|
+
# @version 5.0.0
|
51
|
+
def ping_timeout
|
52
|
+
@last_checkin +
|
53
|
+
(booted? ?
|
54
|
+
@options[:worker_timeout] :
|
55
|
+
@options[:worker_boot_timeout]
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
def term
|
60
|
+
begin
|
61
|
+
if @first_term_sent && (Time.now - @first_term_sent) > @options[:worker_shutdown_timeout]
|
62
|
+
@signal = "KILL"
|
63
|
+
else
|
64
|
+
@term ||= true
|
65
|
+
@first_term_sent ||= Time.now
|
66
|
+
end
|
67
|
+
Process.kill @signal, @pid if @pid
|
68
|
+
rescue Errno::ESRCH
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def kill
|
73
|
+
@signal = 'KILL'
|
74
|
+
term
|
75
|
+
end
|
76
|
+
|
77
|
+
def hup
|
78
|
+
Process.kill "HUP", @pid
|
79
|
+
rescue Errno::ESRCH
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/puma/configuration.rb
CHANGED
@@ -108,16 +108,17 @@ module Puma
|
|
108
108
|
#
|
109
109
|
# It also handles loading plugins.
|
110
110
|
#
|
111
|
-
#
|
111
|
+
# [Note:]
|
112
|
+
# `:port` and `:host` are not valid keys. By the time they make it to the
|
112
113
|
# configuration options they are expected to be incorporated into a `:binds` key.
|
113
114
|
# Under the hood the DSL maps `port` and `host` calls to `:binds`
|
114
115
|
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
116
|
+
# config = Configuration.new({}) do |user_config, file_config, default_config|
|
117
|
+
# user_config.port 3003
|
118
|
+
# end
|
119
|
+
# config.load
|
120
|
+
# puts config.options[:port]
|
121
|
+
# # => 3003
|
121
122
|
#
|
122
123
|
# It is expected that `load` is called on the configuration instance after setting
|
123
124
|
# config. This method expands any values in `config_file` and puts them into the
|
@@ -173,6 +174,7 @@ module Puma
|
|
173
174
|
self
|
174
175
|
end
|
175
176
|
|
177
|
+
# @version 5.0.0
|
176
178
|
def default_max_threads
|
177
179
|
Puma.mri? ? 5 : 16
|
178
180
|
end
|
data/lib/puma/const.rb
CHANGED
@@ -100,8 +100,9 @@ module Puma
|
|
100
100
|
# too taxing on performance.
|
101
101
|
module Const
|
102
102
|
|
103
|
-
PUMA_VERSION = VERSION = "5.0.
|
103
|
+
PUMA_VERSION = VERSION = "5.0.4".freeze
|
104
104
|
CODE_NAME = "Spoony Bard".freeze
|
105
|
+
|
105
106
|
PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
|
106
107
|
|
107
108
|
FAST_TRACK_KA_TIMEOUT = 0.2
|
data/lib/puma/control_cli.rb
CHANGED
@@ -12,6 +12,8 @@ module Puma
|
|
12
12
|
class ControlCLI
|
13
13
|
|
14
14
|
COMMANDS = %w{halt restart phased-restart start stats status stop reload-worker-directory gc gc-stats thread-backtraces refork}
|
15
|
+
|
16
|
+
# @version 5.0.0
|
15
17
|
PRINTABLE_COMMANDS = %w{gc-stats stats thread-backtraces}
|
16
18
|
|
17
19
|
def initialize(argv, stdout=STDOUT, stderr=STDERR)
|
data/lib/puma/detect.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Puma
|
4
|
+
# at present, MiniSSL::Engine is only defined in extension code, not in minissl.rb
|
5
|
+
HAS_SSL = const_defined?(:MiniSSL, false) && MiniSSL.const_defined?(:Engine, false)
|
6
|
+
|
7
|
+
def self.ssl?
|
8
|
+
HAS_SSL
|
9
|
+
end
|
10
|
+
|
4
11
|
IS_JRUBY = defined?(JRUBY_VERSION)
|
5
12
|
|
6
13
|
def self.jruby?
|
@@ -13,10 +20,12 @@ module Puma
|
|
13
20
|
IS_WINDOWS
|
14
21
|
end
|
15
22
|
|
23
|
+
# @version 5.0.0
|
16
24
|
def self.mri?
|
17
25
|
RUBY_ENGINE == 'ruby' || RUBY_ENGINE.nil?
|
18
26
|
end
|
19
27
|
|
28
|
+
# @version 5.0.0
|
20
29
|
def self.forkable?
|
21
30
|
::Process.respond_to?(:fork)
|
22
31
|
end
|
data/lib/puma/dsl.rb
CHANGED
@@ -14,22 +14,23 @@ module Puma
|
|
14
14
|
# end
|
15
15
|
# config.load
|
16
16
|
#
|
17
|
-
# puts config.options[:binds]
|
18
|
-
# "tcp://127.0.0.1:3001"
|
17
|
+
# puts config.options[:binds] # => "tcp://127.0.0.1:3001"
|
19
18
|
#
|
20
19
|
# Used to load file:
|
21
20
|
#
|
22
21
|
# $ cat puma_config.rb
|
23
|
-
#
|
22
|
+
# port 3002
|
23
|
+
#
|
24
|
+
# Resulting configuration:
|
24
25
|
#
|
25
26
|
# config = Configuration.new(config_file: "puma_config.rb")
|
26
27
|
# config.load
|
27
28
|
#
|
28
|
-
# puts config.options[:binds]
|
29
|
-
# # => "tcp://127.0.0.1:3002"
|
29
|
+
# puts config.options[:binds] # => "tcp://127.0.0.1:3002"
|
30
30
|
#
|
31
31
|
# You can also find many examples being used by the test suite in
|
32
32
|
# +test/config+.
|
33
|
+
#
|
33
34
|
class DSL
|
34
35
|
include ConfigDefault
|
35
36
|
|
@@ -98,6 +99,9 @@ module Puma
|
|
98
99
|
# [body]
|
99
100
|
# ]
|
100
101
|
# end
|
102
|
+
#
|
103
|
+
# @see Puma::Configuration#app
|
104
|
+
#
|
101
105
|
def app(obj=nil, &block)
|
102
106
|
obj ||= block
|
103
107
|
|
@@ -160,12 +164,12 @@ module Puma
|
|
160
164
|
#
|
161
165
|
# You can use query parameters within the url to specify options:
|
162
166
|
#
|
163
|
-
#
|
164
|
-
#
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
167
|
+
# * Set the socket backlog depth with +backlog+, default is 1024.
|
168
|
+
# * Set up an SSL certificate with +key+ & +cert+.
|
169
|
+
# * Set whether to optimize for low latency instead of throughput with
|
170
|
+
# +low_latency+, default is to optimize for low latency. This is done
|
171
|
+
# via +Socket::TCP_NODELAY+.
|
172
|
+
# * Set socket permissions with +umask+.
|
169
173
|
#
|
170
174
|
# @example Backlog depth
|
171
175
|
# bind 'unix:///var/run/puma.sock?backlog=512'
|
@@ -175,6 +179,9 @@ module Puma
|
|
175
179
|
# bind 'tcp://0.0.0.0:9292?low_latency=false'
|
176
180
|
# @example Socket permissions
|
177
181
|
# bind 'unix:///var/run/puma.sock?umask=0111'
|
182
|
+
# @see Puma::Runner#load_and_bind
|
183
|
+
# @see Puma::Cluster#run
|
184
|
+
#
|
178
185
|
def bind(url)
|
179
186
|
@options[:binds] ||= []
|
180
187
|
@options[:binds] << url
|
@@ -193,13 +200,14 @@ module Puma
|
|
193
200
|
bind "tcp://#{host}:#{port}"
|
194
201
|
end
|
195
202
|
|
196
|
-
# Define how long persistent connections can be idle before Puma closes
|
197
|
-
#
|
203
|
+
# Define how long persistent connections can be idle before Puma closes them.
|
204
|
+
# @see Puma::Server.new
|
198
205
|
def persistent_timeout(seconds)
|
199
206
|
@options[:persistent_timeout] = Integer(seconds)
|
200
207
|
end
|
201
208
|
|
202
209
|
# Define how long the tcp socket stays open, if no data has been received.
|
210
|
+
# @see Puma::Server.new
|
203
211
|
def first_data_timeout(seconds)
|
204
212
|
@options[:first_data_timeout] = Integer(seconds)
|
205
213
|
end
|
@@ -210,10 +218,11 @@ module Puma
|
|
210
218
|
@options[:clean_thread_locals] = which
|
211
219
|
end
|
212
220
|
|
213
|
-
# When shutting down, drain the accept socket of pending
|
214
|
-
#
|
215
|
-
#
|
216
|
-
#
|
221
|
+
# When shutting down, drain the accept socket of pending connections and
|
222
|
+
# process them. This loops over the accept socket until there are no more
|
223
|
+
# read events and then stops looking and waits for the requests to finish.
|
224
|
+
# @see Puma::Server#graceful_shutdown
|
225
|
+
#
|
217
226
|
def drain_on_shutdown(which=true)
|
218
227
|
@options[:drain_on_shutdown] = which
|
219
228
|
end
|
@@ -236,6 +245,7 @@ module Puma
|
|
236
245
|
#
|
237
246
|
# Puma always waits a few seconds after killing a thread for it to try
|
238
247
|
# to finish up it's work, even in :immediately mode.
|
248
|
+
# @see Puma::Server#graceful_shutdown
|
239
249
|
def force_shutdown_after(val=:forever)
|
240
250
|
i = case val
|
241
251
|
when :forever
|
@@ -315,7 +325,7 @@ module Puma
|
|
315
325
|
@options[:early_hints] = answer
|
316
326
|
end
|
317
327
|
|
318
|
-
# Redirect STDOUT and STDERR to files specified. The +append+ parameter
|
328
|
+
# Redirect +STDOUT+ and +STDERR+ to files specified. The +append+ parameter
|
319
329
|
# specifies whether the output is appended, the default is +false+.
|
320
330
|
#
|
321
331
|
# @example
|
@@ -356,8 +366,8 @@ module Puma
|
|
356
366
|
@options[:max_threads] = max
|
357
367
|
end
|
358
368
|
|
359
|
-
# Instead of
|
360
|
-
# can also use the
|
369
|
+
# Instead of `bind 'ssl://127.0.0.1:9292?key=key_path&cert=cert_path'` you
|
370
|
+
# can also use the this method.
|
361
371
|
#
|
362
372
|
# @example
|
363
373
|
# ssl_bind '127.0.0.1', '9292', {
|
@@ -403,6 +413,8 @@ module Puma
|
|
403
413
|
#
|
404
414
|
# @example
|
405
415
|
# state_permission 0600
|
416
|
+
# @version 5.0.0
|
417
|
+
#
|
406
418
|
def state_permission(permission)
|
407
419
|
@options[:state_permission] = permission
|
408
420
|
end
|
@@ -413,6 +425,7 @@ module Puma
|
|
413
425
|
# The default is 0.
|
414
426
|
#
|
415
427
|
# @note Cluster mode only.
|
428
|
+
# @see Puma::Cluster
|
416
429
|
def workers(count)
|
417
430
|
@options[:workers] = count.to_i
|
418
431
|
end
|
@@ -516,7 +529,8 @@ module Puma
|
|
516
529
|
# on_refork do
|
517
530
|
# 3.times {GC.start}
|
518
531
|
# end
|
519
|
-
|
532
|
+
# @version 5.0.0
|
533
|
+
#
|
520
534
|
def on_refork(&block)
|
521
535
|
@options[:before_refork] ||= []
|
522
536
|
@options[:before_refork] << block
|
@@ -582,7 +596,7 @@ module Puma
|
|
582
596
|
# new Bundler context and thus can float around as the release
|
583
597
|
# dictates.
|
584
598
|
#
|
585
|
-
#
|
599
|
+
# @see extra_runtime_dependencies
|
586
600
|
#
|
587
601
|
# @note This is incompatible with +preload_app!+.
|
588
602
|
# @note This is only supported for RubyGems 2.2+
|
@@ -599,6 +613,9 @@ module Puma
|
|
599
613
|
#
|
600
614
|
# @example
|
601
615
|
# raise_exception_on_sigterm false
|
616
|
+
# @see Puma::Launcher#setup_signals
|
617
|
+
# @see Puma::Cluster#setup_signals
|
618
|
+
#
|
602
619
|
def raise_exception_on_sigterm(answer=true)
|
603
620
|
@options[:raise_exception_on_sigterm] = answer
|
604
621
|
end
|
@@ -614,6 +631,8 @@ module Puma
|
|
614
631
|
# extra_runtime_dependencies ['gem_name_1', 'gem_name_2']
|
615
632
|
# @example
|
616
633
|
# extra_runtime_dependencies ['puma_worker_killer', 'puma-heroku']
|
634
|
+
# @see Puma::Launcher#extra_runtime_deps_directories
|
635
|
+
#
|
617
636
|
def extra_runtime_dependencies(answer = [])
|
618
637
|
@options[:extra_runtime_dependencies] = Array(answer)
|
619
638
|
end
|
@@ -641,6 +660,8 @@ module Puma
|
|
641
660
|
# @note Cluster mode only.
|
642
661
|
# @example
|
643
662
|
# worker_timeout 60
|
663
|
+
# @see Puma::Cluster::Worker#ping_timeout
|
664
|
+
#
|
644
665
|
def worker_timeout(timeout)
|
645
666
|
timeout = Integer(timeout)
|
646
667
|
min = Const::WORKER_CHECK_INTERVAL
|
@@ -657,15 +678,20 @@ module Puma
|
|
657
678
|
# If unspecified, this defaults to the value of worker_timeout.
|
658
679
|
#
|
659
680
|
# @note Cluster mode only.
|
660
|
-
#
|
681
|
+
#
|
682
|
+
# @example
|
661
683
|
# worker_boot_timeout 60
|
684
|
+
# @see Puma::Cluster::Worker#ping_timeout
|
685
|
+
#
|
662
686
|
def worker_boot_timeout(timeout)
|
663
687
|
@options[:worker_boot_timeout] = Integer(timeout)
|
664
688
|
end
|
665
689
|
|
666
|
-
# Set the timeout for worker shutdown
|
690
|
+
# Set the timeout for worker shutdown.
|
667
691
|
#
|
668
692
|
# @note Cluster mode only.
|
693
|
+
# @see Puma::Cluster::Worker#term
|
694
|
+
#
|
669
695
|
def worker_shutdown_timeout(timeout)
|
670
696
|
@options[:worker_shutdown_timeout] = Integer(timeout)
|
671
697
|
end
|
@@ -683,6 +709,7 @@ module Puma
|
|
683
709
|
# slow clients will occupy a handler thread while the request
|
684
710
|
# is being sent. A reverse proxy, such as nginx, can handle
|
685
711
|
# slow clients and queue requests before they reach Puma.
|
712
|
+
# @see Puma::Server
|
686
713
|
def queue_requests(answer=true)
|
687
714
|
@options[:queue_requests] = answer
|
688
715
|
end
|
@@ -690,6 +717,7 @@ module Puma
|
|
690
717
|
# When a shutdown is requested, the backtraces of all the
|
691
718
|
# threads will be written to $stdout. This can help figure
|
692
719
|
# out why shutdown is hanging.
|
720
|
+
#
|
693
721
|
def shutdown_debug(val=true)
|
694
722
|
@options[:shutdown_debug] = val
|
695
723
|
end
|
@@ -700,6 +728,10 @@ module Puma
|
|
700
728
|
# requests to pick up new requests first.
|
701
729
|
#
|
702
730
|
# Only works on MRI. For all other interpreters, this setting does nothing.
|
731
|
+
# @see Puma::Server#handle_servers
|
732
|
+
# @see Puma::ThreadPool#wait_for_less_busy_worker
|
733
|
+
# @version 5.0.0
|
734
|
+
#
|
703
735
|
def wait_for_less_busy_worker(val=0.005)
|
704
736
|
@options[:wait_for_less_busy_worker] = val.to_f
|
705
737
|
end
|
@@ -711,18 +743,18 @@ module Puma
|
|
711
743
|
#
|
712
744
|
# There are 4 possible values:
|
713
745
|
#
|
714
|
-
#
|
715
|
-
#
|
716
|
-
#
|
717
|
-
#
|
718
|
-
#
|
719
|
-
#
|
720
|
-
#
|
721
|
-
#
|
722
|
-
#
|
723
|
-
#
|
724
|
-
#
|
725
|
-
#
|
746
|
+
# 1. **:socket** (the default) - read the peername from the socket using the
|
747
|
+
# syscall. This is the normal behavior.
|
748
|
+
# 2. **:localhost** - set the remote address to "127.0.0.1"
|
749
|
+
# 3. **header: <http_header>**- set the remote address to the value of the
|
750
|
+
# provided http header. For instance:
|
751
|
+
# `set_remote_address header: "X-Real-IP"`.
|
752
|
+
# Only the first word (as separated by spaces or comma) is used, allowing
|
753
|
+
# headers such as X-Forwarded-For to be used as well.
|
754
|
+
# 4. **\<Any string\>** - this allows you to hardcode remote address to any value
|
755
|
+
# you wish. Because Puma never uses this field anyway, it's format is
|
756
|
+
# entirely in your hands.
|
757
|
+
#
|
726
758
|
def set_remote_address(val=:socket)
|
727
759
|
case val
|
728
760
|
when :socket
|
@@ -756,6 +788,8 @@ module Puma
|
|
756
788
|
# (default 1000), or pass 0 to disable auto refork.
|
757
789
|
#
|
758
790
|
# @note Cluster mode only.
|
791
|
+
# @version 5.0.0
|
792
|
+
#
|
759
793
|
def fork_worker(after_requests=1000)
|
760
794
|
@options[:fork_worker] = Integer(after_requests)
|
761
795
|
end
|
@@ -769,6 +803,10 @@ module Puma
|
|
769
803
|
# also increase time to boot and fork. See your logs for details on how much
|
770
804
|
# time this adds to your boot process. For most apps, it will be less than one
|
771
805
|
# second.
|
806
|
+
#
|
807
|
+
# @see Puma::Cluster#nakayoshi_gc
|
808
|
+
# @version 5.0.0
|
809
|
+
#
|
772
810
|
def nakayoshi_fork(enabled=true)
|
773
811
|
@options[:nakayoshi_fork] = enabled
|
774
812
|
end
|