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
data/lib/puma/single.rb
CHANGED
@@ -13,6 +13,7 @@ module Puma
|
|
13
13
|
# gets created via the `start_server` method from the `Puma::Runner` class
|
14
14
|
# that this inherits from.
|
15
15
|
class Single < Runner
|
16
|
+
# @!attribute [r] stats
|
16
17
|
def stats
|
17
18
|
{
|
18
19
|
started_at: @started_at.utc.iso8601
|
@@ -49,7 +50,7 @@ module Puma
|
|
49
50
|
start_control
|
50
51
|
|
51
52
|
@server = server = start_server
|
52
|
-
|
53
|
+
server_thread = server.run
|
53
54
|
|
54
55
|
log "Use Ctrl-C to stop"
|
55
56
|
redirect_io
|
@@ -57,7 +58,7 @@ module Puma
|
|
57
58
|
@launcher.events.fire_on_booted!
|
58
59
|
|
59
60
|
begin
|
60
|
-
|
61
|
+
server_thread.join
|
61
62
|
rescue Interrupt
|
62
63
|
# Swallow it
|
63
64
|
end
|
data/lib/puma/thread_pool.rb
CHANGED
@@ -62,11 +62,13 @@ module Puma
|
|
62
62
|
end
|
63
63
|
|
64
64
|
@clean_thread_locals = false
|
65
|
+
@force_shutdown = false
|
66
|
+
@shutdown_mutex = Mutex.new
|
65
67
|
end
|
66
68
|
|
67
69
|
attr_reader :spawned, :trim_requested, :waiting
|
68
70
|
attr_accessor :clean_thread_locals
|
69
|
-
attr_accessor :out_of_band_hook
|
71
|
+
attr_accessor :out_of_band_hook # @version 5.0.0
|
70
72
|
|
71
73
|
def self.clean_thread_locals
|
72
74
|
Thread.current.keys.each do |key| # rubocop: disable Performance/HashEachMethods
|
@@ -80,10 +82,13 @@ module Puma
|
|
80
82
|
with_mutex { @todo.size }
|
81
83
|
end
|
82
84
|
|
85
|
+
# @!attribute [r] pool_capacity
|
83
86
|
def pool_capacity
|
84
87
|
waiting + (@max - spawned)
|
85
88
|
end
|
86
89
|
|
90
|
+
# @!attribute [r] busy_threads
|
91
|
+
# @version 5.0.0
|
87
92
|
def busy_threads
|
88
93
|
with_mutex { @spawned - @waiting + @todo.size }
|
89
94
|
end
|
@@ -151,6 +156,7 @@ module Puma
|
|
151
156
|
|
152
157
|
private :spawn_thread
|
153
158
|
|
159
|
+
# @version 5.0.0
|
154
160
|
def trigger_out_of_band_hook
|
155
161
|
return false unless out_of_band_hook && out_of_band_hook.any?
|
156
162
|
|
@@ -166,6 +172,7 @@ module Puma
|
|
166
172
|
|
167
173
|
private :trigger_out_of_band_hook
|
168
174
|
|
175
|
+
# @version 5.0.0
|
169
176
|
def with_mutex(&block)
|
170
177
|
@mutex.owned? ?
|
171
178
|
yield :
|
@@ -231,6 +238,7 @@ module Puma
|
|
231
238
|
end
|
232
239
|
end
|
233
240
|
|
241
|
+
# @version 5.0.0
|
234
242
|
def wait_for_less_busy_worker(delay_s)
|
235
243
|
# Ruby MRI does GVL, this can result
|
236
244
|
# in processing contention when multiple threads
|
@@ -318,6 +326,19 @@ module Puma
|
|
318
326
|
@reaper.start!
|
319
327
|
end
|
320
328
|
|
329
|
+
# Allows ThreadPool::ForceShutdown to be raised within the
|
330
|
+
# provided block if the thread is forced to shutdown during execution.
|
331
|
+
def with_force_shutdown
|
332
|
+
t = Thread.current
|
333
|
+
@shutdown_mutex.synchronize do
|
334
|
+
raise ForceShutdown if @force_shutdown
|
335
|
+
t[:with_force_shutdown] = true
|
336
|
+
end
|
337
|
+
yield
|
338
|
+
ensure
|
339
|
+
t[:with_force_shutdown] = false
|
340
|
+
end
|
341
|
+
|
321
342
|
# Tell all threads in the pool to exit and wait for them to finish.
|
322
343
|
# Wait +timeout+ seconds then raise +ForceShutdown+ in remaining threads.
|
323
344
|
# Next, wait an extra +grace+ seconds then force-kill remaining threads.
|
@@ -352,8 +373,11 @@ module Puma
|
|
352
373
|
join.call(timeout)
|
353
374
|
|
354
375
|
# If threads are still running, raise ForceShutdown and wait to finish.
|
355
|
-
|
356
|
-
|
376
|
+
@shutdown_mutex.synchronize do
|
377
|
+
@force_shutdown = true
|
378
|
+
threads.each do |t|
|
379
|
+
t.raise ForceShutdown if t[:with_force_shutdown]
|
380
|
+
end
|
357
381
|
end
|
358
382
|
join.call(SHUTDOWN_GRACE_TIME)
|
359
383
|
|
data/lib/puma/util.rb
CHANGED
@@ -23,6 +23,17 @@ module Puma
|
|
23
23
|
end
|
24
24
|
module_function :unescape
|
25
25
|
|
26
|
+
# @version 5.0.0
|
27
|
+
def nakayoshi_gc(events)
|
28
|
+
events.log "! Promoting existing objects to old generation..."
|
29
|
+
4.times { GC.start(full_mark: false) }
|
30
|
+
if GC.respond_to?(:compact)
|
31
|
+
events.log "! Compacting..."
|
32
|
+
GC.compact
|
33
|
+
end
|
34
|
+
events.log "! Friendly fork preparation complete."
|
35
|
+
end
|
36
|
+
|
26
37
|
DEFAULT_SEP = /[&;] */n
|
27
38
|
|
28
39
|
# Stolen from Mongrel, with some small modifications:
|
@@ -72,6 +83,7 @@ module Puma
|
|
72
83
|
end
|
73
84
|
end
|
74
85
|
|
86
|
+
# @!attribute [r] to_hash
|
75
87
|
def to_hash
|
76
88
|
hash = {}
|
77
89
|
each { |k,v| hash[k] = v }
|
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
|
+
version: 5.0.4
|
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-
|
11
|
+
date: 2020-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,9 +52,6 @@ files:
|
|
52
52
|
- docs/jungle/rc.d/README.md
|
53
53
|
- docs/jungle/rc.d/puma
|
54
54
|
- docs/jungle/rc.d/puma.conf
|
55
|
-
- docs/jungle/upstart/README.md
|
56
|
-
- docs/jungle/upstart/puma-manager.conf
|
57
|
-
- docs/jungle/upstart/puma.conf
|
58
55
|
- docs/nginx.md
|
59
56
|
- docs/plugins.md
|
60
57
|
- docs/restart.md
|
@@ -69,17 +66,19 @@ files:
|
|
69
66
|
- ext/puma_http11/http11_parser.rl
|
70
67
|
- ext/puma_http11/http11_parser_common.rl
|
71
68
|
- ext/puma_http11/mini_ssl.c
|
69
|
+
- ext/puma_http11/no_ssl/PumaHttp11Service.java
|
72
70
|
- ext/puma_http11/org/jruby/puma/Http11.java
|
73
71
|
- ext/puma_http11/org/jruby/puma/Http11Parser.java
|
74
72
|
- ext/puma_http11/org/jruby/puma/MiniSSL.java
|
75
73
|
- ext/puma_http11/puma_http11.c
|
76
74
|
- lib/puma.rb
|
77
|
-
- lib/puma/accept_nonblock.rb
|
78
75
|
- lib/puma/app/status.rb
|
79
76
|
- lib/puma/binder.rb
|
80
77
|
- lib/puma/cli.rb
|
81
78
|
- lib/puma/client.rb
|
82
79
|
- lib/puma/cluster.rb
|
80
|
+
- lib/puma/cluster/worker.rb
|
81
|
+
- lib/puma/cluster/worker_handle.rb
|
83
82
|
- lib/puma/commonlogger.rb
|
84
83
|
- lib/puma/configuration.rb
|
85
84
|
- lib/puma/const.rb
|
@@ -97,10 +96,12 @@ files:
|
|
97
96
|
- lib/puma/plugin.rb
|
98
97
|
- lib/puma/plugin/tmp_restart.rb
|
99
98
|
- lib/puma/puma_http11.jar
|
99
|
+
- lib/puma/queue_close.rb
|
100
100
|
- lib/puma/rack/builder.rb
|
101
101
|
- lib/puma/rack/urlmap.rb
|
102
102
|
- lib/puma/rack_default.rb
|
103
103
|
- lib/puma/reactor.rb
|
104
|
+
- lib/puma/request.rb
|
104
105
|
- lib/puma/runner.rb
|
105
106
|
- lib/puma/server.rb
|
106
107
|
- lib/puma/single.rb
|
@@ -129,9 +130,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
130
|
version: '2.2'
|
130
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
132
|
requirements:
|
132
|
-
- - "
|
133
|
+
- - ">="
|
133
134
|
- !ruby/object:Gem::Version
|
134
|
-
version:
|
135
|
+
version: '0'
|
135
136
|
requirements: []
|
136
137
|
rubygems_version: 3.0.6
|
137
138
|
signing_key:
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# Puma as a service using Upstart
|
2
|
-
|
3
|
-
Manage multiple Puma servers as services on the same box using Ubuntu upstart.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
# Copy the scripts to services directory
|
8
|
-
sudo cp puma.conf puma-manager.conf /etc/init
|
9
|
-
|
10
|
-
# Create an empty configuration file
|
11
|
-
sudo touch /etc/puma.conf
|
12
|
-
|
13
|
-
## Managing the jungle
|
14
|
-
|
15
|
-
Puma apps are referenced in /etc/puma.conf by default. Add each app's path as a new line, e.g.:
|
16
|
-
|
17
|
-
```
|
18
|
-
/home/apps/my-cool-ruby-app
|
19
|
-
/home/apps/another-app/current
|
20
|
-
```
|
21
|
-
|
22
|
-
Start the jungle running:
|
23
|
-
|
24
|
-
`sudo start puma-manager`
|
25
|
-
|
26
|
-
This script will run at boot time.
|
27
|
-
|
28
|
-
Start a single puma like this:
|
29
|
-
|
30
|
-
`sudo start puma app=/path/to/app`
|
31
|
-
|
32
|
-
## Logs
|
33
|
-
|
34
|
-
Everything is logged by upstart, defaulting to `/var/log/upstart`.
|
35
|
-
|
36
|
-
Each puma instance is named after its directory, so for an app called `/home/apps/my-app` the log file would be `/var/log/upstart/puma-_home_apps_my-app.log`.
|
37
|
-
|
38
|
-
## Conventions
|
39
|
-
|
40
|
-
* The script expects:
|
41
|
-
* a config file to exist under `config/puma.rb` in your app. E.g.: `/home/apps/my-app/config/puma.rb`.
|
42
|
-
* a temporary folder to put the PID, socket and state files to exist called `tmp/puma`. E.g.: `/home/apps/my-app/tmp/puma`. Puma will take care of the files for you.
|
43
|
-
|
44
|
-
You can always change those defaults by editing the scripts.
|
45
|
-
|
46
|
-
## Here's what a minimal app's config file should have
|
47
|
-
|
48
|
-
```
|
49
|
-
pidfile "/path/to/app/tmp/puma/pid"
|
50
|
-
state_path "/path/to/app/tmp/puma/state"
|
51
|
-
activate_control_app
|
52
|
-
```
|
53
|
-
|
54
|
-
## Before starting...
|
55
|
-
|
56
|
-
You need to customise `puma.conf` to:
|
57
|
-
|
58
|
-
* Set the right user your app should be running on unless you want root to execute it!
|
59
|
-
* Look for `setuid apps` and `setgid apps`, uncomment those lines and replace `apps` to whatever your deployment user is.
|
60
|
-
* Replace `apps` on the paths (or set the right paths to your user's home) everywhere else.
|
61
|
-
* Uncomment the source lines for `rbenv` or `rvm` support unless you use a system wide installation of Ruby.
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# /etc/init/puma-manager.conf - manage a set of Pumas
|
2
|
-
|
3
|
-
# This example config should work with Ubuntu 12.04+. It
|
4
|
-
# allows you to manage multiple Puma instances with
|
5
|
-
# Upstart, Ubuntu's native service management tool.
|
6
|
-
#
|
7
|
-
# See puma.conf for how to manage a single Puma instance.
|
8
|
-
#
|
9
|
-
# Use "stop puma-manager" to stop all Puma instances.
|
10
|
-
# Use "start puma-manager" to start all instances.
|
11
|
-
# Use "restart puma-manager" to restart all instances.
|
12
|
-
# Crazy, right?
|
13
|
-
#
|
14
|
-
|
15
|
-
description "Manages the set of puma processes"
|
16
|
-
|
17
|
-
# This starts upon bootup and stops on shutdown
|
18
|
-
start on runlevel [2345]
|
19
|
-
stop on runlevel [06]
|
20
|
-
|
21
|
-
# Set this to the number of Puma processes you want
|
22
|
-
# to run on this machine
|
23
|
-
env PUMA_CONF="/etc/puma.conf"
|
24
|
-
|
25
|
-
pre-start script
|
26
|
-
for i in `cat $PUMA_CONF`; do
|
27
|
-
app=`echo $i | cut -d , -f 1`
|
28
|
-
logger -t "puma-manager" "Starting $app"
|
29
|
-
start puma app=$app
|
30
|
-
done
|
31
|
-
end script
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# /etc/init/puma.conf - Puma config
|
2
|
-
|
3
|
-
# This example config should work with Ubuntu 12.04+. It
|
4
|
-
# allows you to manage multiple Puma instances with
|
5
|
-
# Upstart, Ubuntu's native service management tool.
|
6
|
-
#
|
7
|
-
# See puma-manager.conf for how to manage all Puma instances at once.
|
8
|
-
#
|
9
|
-
# Save this config as /etc/init/puma.conf then manage puma with:
|
10
|
-
# sudo start puma app=PATH_TO_APP
|
11
|
-
# sudo stop puma app=PATH_TO_APP
|
12
|
-
# sudo status puma app=PATH_TO_APP
|
13
|
-
#
|
14
|
-
# or use the service command:
|
15
|
-
# sudo service puma {start,stop,restart,status}
|
16
|
-
#
|
17
|
-
|
18
|
-
description "Puma Background Worker"
|
19
|
-
|
20
|
-
# no "start on", we don't want to automatically start
|
21
|
-
stop on (stopping puma-manager or runlevel [06])
|
22
|
-
|
23
|
-
# change apps to match your deployment user if you want to use this as a less privileged user (recommended!)
|
24
|
-
setuid apps
|
25
|
-
setgid apps
|
26
|
-
|
27
|
-
respawn
|
28
|
-
respawn limit 3 30
|
29
|
-
|
30
|
-
instance ${app}
|
31
|
-
|
32
|
-
script
|
33
|
-
# this script runs in /bin/sh by default
|
34
|
-
# respawn as bash so we can source in rbenv/rvm
|
35
|
-
# quoted heredoc to tell /bin/sh not to interpret
|
36
|
-
# variables
|
37
|
-
|
38
|
-
# source ENV variables manually as Upstart doesn't, eg:
|
39
|
-
#. /etc/environment
|
40
|
-
|
41
|
-
exec /bin/bash <<'EOT'
|
42
|
-
# set HOME to the setuid user's home, there doesn't seem to be a better, portable way
|
43
|
-
export HOME="$(eval echo ~$(id -un))"
|
44
|
-
|
45
|
-
if [ -d "/usr/local/rbenv/bin" ]; then
|
46
|
-
export PATH="/usr/local/rbenv/bin:/usr/local/rbenv/shims:$PATH"
|
47
|
-
elif [ -d "$HOME/.rbenv/bin" ]; then
|
48
|
-
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
|
49
|
-
elif [ -f /etc/profile.d/rvm.sh ]; then
|
50
|
-
source /etc/profile.d/rvm.sh
|
51
|
-
elif [ -f /usr/local/rvm/scripts/rvm ]; then
|
52
|
-
source /etc/profile.d/rvm.sh
|
53
|
-
elif [ -f "$HOME/.rvm/scripts/rvm" ]; then
|
54
|
-
source "$HOME/.rvm/scripts/rvm"
|
55
|
-
elif [ -f /usr/local/share/chruby/chruby.sh ]; then
|
56
|
-
source /usr/local/share/chruby/chruby.sh
|
57
|
-
if [ -f /usr/local/share/chruby/auto.sh ]; then
|
58
|
-
source /usr/local/share/chruby/auto.sh
|
59
|
-
fi
|
60
|
-
# if you aren't using auto, set your version here
|
61
|
-
# chruby 2.0.0
|
62
|
-
fi
|
63
|
-
|
64
|
-
cd $app
|
65
|
-
logger -t puma "Starting server: $app"
|
66
|
-
|
67
|
-
exec bundle exec puma -C config/puma.rb
|
68
|
-
EOT
|
69
|
-
end script
|
data/lib/puma/accept_nonblock.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'openssl'
|
4
|
-
|
5
|
-
module OpenSSL
|
6
|
-
module SSL
|
7
|
-
class SSLServer
|
8
|
-
unless public_method_defined? :accept_nonblock
|
9
|
-
def accept_nonblock
|
10
|
-
sock = @svr.accept_nonblock
|
11
|
-
|
12
|
-
begin
|
13
|
-
ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
|
14
|
-
ssl.sync_close = true
|
15
|
-
ssl.accept if @start_immediately
|
16
|
-
ssl
|
17
|
-
rescue SSLError => ex
|
18
|
-
if ssl
|
19
|
-
ssl.close
|
20
|
-
else
|
21
|
-
sock.close
|
22
|
-
end
|
23
|
-
raise ex
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|