puma 5.0.0.beta1-java → 5.0.3-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 +1188 -559
- data/README.md +15 -8
- data/bin/puma-wild +3 -9
- data/docs/architecture.md +3 -3
- data/docs/deployment.md +10 -7
- 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 +7 -7
- data/docs/systemd.md +1 -1
- data/ext/puma_http11/ext_help.h +1 -1
- data/ext/puma_http11/http11_parser.c +3 -1
- data/ext/puma_http11/http11_parser.rl +3 -1
- data/ext/puma_http11/mini_ssl.c +53 -38
- data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +77 -18
- data/ext/puma_http11/puma_http11.c +22 -11
- data/lib/puma.rb +16 -0
- data/lib/puma/app/status.rb +47 -44
- data/lib/puma/binder.rb +40 -12
- data/lib/puma/client.rb +68 -82
- data/lib/puma/cluster.rb +30 -187
- data/lib/puma/cluster/worker.rb +170 -0
- data/lib/puma/cluster/worker_handle.rb +83 -0
- data/lib/puma/commonlogger.rb +2 -2
- 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 +77 -39
- data/lib/puma/error_logger.rb +97 -0
- data/lib/puma/events.rb +37 -31
- data/lib/puma/launcher.rb +20 -10
- data/lib/puma/minissl.rb +55 -10
- 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 +7 -19
- data/lib/puma/server.rb +229 -506
- data/lib/puma/single.rb +3 -2
- data/lib/puma/state_file.rb +1 -1
- data/lib/puma/thread_pool.rb +32 -5
- data/lib/puma/util.rb +12 -0
- metadata +12 -10
- 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/state_file.rb
CHANGED
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
|
@@ -122,8 +127,11 @@ module Puma
|
|
122
127
|
@out_of_band_pending = false
|
123
128
|
end
|
124
129
|
not_full.signal
|
125
|
-
|
126
|
-
|
130
|
+
begin
|
131
|
+
not_empty.wait mutex
|
132
|
+
ensure
|
133
|
+
@waiting -= 1
|
134
|
+
end
|
127
135
|
end
|
128
136
|
|
129
137
|
work = todo.shift
|
@@ -148,6 +156,7 @@ module Puma
|
|
148
156
|
|
149
157
|
private :spawn_thread
|
150
158
|
|
159
|
+
# @version 5.0.0
|
151
160
|
def trigger_out_of_band_hook
|
152
161
|
return false unless out_of_band_hook && out_of_band_hook.any?
|
153
162
|
|
@@ -163,6 +172,7 @@ module Puma
|
|
163
172
|
|
164
173
|
private :trigger_out_of_band_hook
|
165
174
|
|
175
|
+
# @version 5.0.0
|
166
176
|
def with_mutex(&block)
|
167
177
|
@mutex.owned? ?
|
168
178
|
yield :
|
@@ -228,6 +238,7 @@ module Puma
|
|
228
238
|
end
|
229
239
|
end
|
230
240
|
|
241
|
+
# @version 5.0.0
|
231
242
|
def wait_for_less_busy_worker(delay_s)
|
232
243
|
# Ruby MRI does GVL, this can result
|
233
244
|
# in processing contention when multiple threads
|
@@ -315,6 +326,19 @@ module Puma
|
|
315
326
|
@reaper.start!
|
316
327
|
end
|
317
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
|
+
|
318
342
|
# Tell all threads in the pool to exit and wait for them to finish.
|
319
343
|
# Wait +timeout+ seconds then raise +ForceShutdown+ in remaining threads.
|
320
344
|
# Next, wait an extra +grace+ seconds then force-kill remaining threads.
|
@@ -349,8 +373,11 @@ module Puma
|
|
349
373
|
join.call(timeout)
|
350
374
|
|
351
375
|
# If threads are still running, raise ForceShutdown and wait to finish.
|
352
|
-
|
353
|
-
|
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
|
354
381
|
end
|
355
382
|
join.call(SHUTDOWN_GRACE_TIME)
|
356
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.3
|
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-26 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,23 +66,26 @@ 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
|
86
85
|
- lib/puma/control_cli.rb
|
87
86
|
- lib/puma/detect.rb
|
88
87
|
- lib/puma/dsl.rb
|
88
|
+
- lib/puma/error_logger.rb
|
89
89
|
- lib/puma/events.rb
|
90
90
|
- lib/puma/io_buffer.rb
|
91
91
|
- lib/puma/jruby_restart.rb
|
@@ -96,10 +96,12 @@ files:
|
|
96
96
|
- lib/puma/plugin.rb
|
97
97
|
- lib/puma/plugin/tmp_restart.rb
|
98
98
|
- lib/puma/puma_http11.jar
|
99
|
+
- lib/puma/queue_close.rb
|
99
100
|
- lib/puma/rack/builder.rb
|
100
101
|
- lib/puma/rack/urlmap.rb
|
101
102
|
- lib/puma/rack_default.rb
|
102
103
|
- lib/puma/reactor.rb
|
104
|
+
- lib/puma/request.rb
|
103
105
|
- lib/puma/runner.rb
|
104
106
|
- lib/puma/server.rb
|
105
107
|
- lib/puma/single.rb
|
@@ -109,13 +111,13 @@ files:
|
|
109
111
|
- lib/rack/handler/puma.rb
|
110
112
|
- tools/Dockerfile
|
111
113
|
- tools/trickletest.rb
|
112
|
-
homepage:
|
114
|
+
homepage: https://puma.io
|
113
115
|
licenses:
|
114
116
|
- BSD-3-Clause
|
115
117
|
metadata:
|
116
118
|
bug_tracker_uri: https://github.com/puma/puma/issues
|
117
119
|
changelog_uri: https://github.com/puma/puma/blob/master/History.md
|
118
|
-
homepage_uri:
|
120
|
+
homepage_uri: https://puma.io
|
119
121
|
source_code_uri: https://github.com/puma/puma
|
120
122
|
post_install_message:
|
121
123
|
rdoc_options: []
|
@@ -128,9 +130,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
130
|
version: '2.2'
|
129
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
132
|
requirements:
|
131
|
-
- - "
|
133
|
+
- - ">="
|
132
134
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
135
|
+
version: '0'
|
134
136
|
requirements: []
|
135
137
|
rubygems_version: 3.0.6
|
136
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
|