puma 3.12.0 → 5.6.8
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 +1620 -439
- data/LICENSE +23 -20
- data/README.md +175 -63
- data/bin/puma-wild +3 -9
- data/docs/architecture.md +59 -21
- data/docs/compile_options.md +21 -0
- data/docs/deployment.md +69 -58
- data/docs/fork_worker.md +33 -0
- data/docs/jungle/README.md +9 -0
- data/{tools → docs}/jungle/rc.d/README.md +1 -1
- data/{tools → docs}/jungle/rc.d/puma +2 -2
- data/docs/kubernetes.md +66 -0
- data/docs/nginx.md +1 -1
- data/docs/plugins.md +22 -12
- data/docs/rails_dev_mode.md +28 -0
- data/docs/restart.md +47 -22
- data/docs/signals.md +13 -11
- data/docs/stats.md +142 -0
- data/docs/systemd.md +95 -120
- data/ext/puma_http11/PumaHttp11Service.java +2 -2
- data/ext/puma_http11/ext_help.h +1 -1
- data/ext/puma_http11/extconf.rb +57 -2
- data/ext/puma_http11/http11_parser.c +105 -117
- data/ext/puma_http11/http11_parser.h +1 -1
- data/ext/puma_http11/http11_parser.java.rl +22 -38
- data/ext/puma_http11/http11_parser.rl +4 -2
- data/ext/puma_http11/http11_parser_common.rl +4 -4
- data/ext/puma_http11/mini_ssl.c +347 -94
- data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
- data/ext/puma_http11/org/jruby/puma/Http11.java +108 -116
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +84 -99
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +124 -71
- data/ext/puma_http11/puma_http11.c +35 -51
- data/lib/puma/app/status.rb +71 -49
- data/lib/puma/binder.rb +241 -143
- data/lib/puma/cli.rb +30 -18
- data/lib/puma/client.rb +379 -229
- data/lib/puma/cluster/worker.rb +173 -0
- data/lib/puma/cluster/worker_handle.rb +94 -0
- data/lib/puma/cluster.rb +249 -232
- data/lib/puma/commonlogger.rb +4 -2
- data/lib/puma/configuration.rb +63 -51
- data/lib/puma/const.rb +44 -21
- data/lib/puma/control_cli.rb +123 -73
- data/lib/puma/detect.rb +31 -2
- data/lib/puma/dsl.rb +631 -125
- data/lib/puma/error_logger.rb +104 -0
- data/lib/puma/events.rb +57 -31
- data/lib/puma/io_buffer.rb +9 -5
- data/lib/puma/jruby_restart.rb +2 -58
- data/lib/puma/json_serialization.rb +96 -0
- data/lib/puma/launcher.rb +196 -70
- data/lib/puma/minissl/context_builder.rb +81 -0
- data/lib/puma/minissl.rb +172 -65
- data/lib/puma/null_io.rb +20 -1
- data/lib/puma/plugin/tmp_restart.rb +2 -0
- data/lib/puma/plugin.rb +9 -13
- data/lib/puma/queue_close.rb +26 -0
- data/lib/puma/rack/builder.rb +5 -6
- data/lib/puma/rack/urlmap.rb +2 -0
- data/lib/puma/rack_default.rb +2 -0
- data/lib/puma/reactor.rb +87 -316
- data/lib/puma/request.rb +476 -0
- data/lib/puma/runner.rb +50 -55
- data/lib/puma/server.rb +307 -695
- data/lib/puma/single.rb +13 -67
- data/lib/puma/state_file.rb +49 -7
- data/lib/puma/systemd.rb +46 -0
- data/lib/puma/thread_pool.rb +134 -82
- data/lib/puma/util.rb +34 -10
- data/lib/puma.rb +56 -0
- data/lib/rack/handler/puma.rb +8 -6
- data/lib/rack/version_restriction.rb +15 -0
- data/tools/Dockerfile +16 -0
- data/tools/trickletest.rb +0 -1
- metadata +49 -32
- data/ext/puma_http11/io_buffer.c +0 -155
- data/lib/puma/accept_nonblock.rb +0 -23
- data/lib/puma/compat.rb +0 -14
- data/lib/puma/convenient.rb +0 -23
- data/lib/puma/daemon_ext.rb +0 -31
- data/lib/puma/delegation.rb +0 -11
- data/lib/puma/java_io_buffer.rb +0 -45
- data/lib/puma/rack/backports/uri/common_193.rb +0 -33
- data/lib/puma/tcp_logger.rb +0 -39
- data/tools/jungle/README.md +0 -19
- data/tools/jungle/init.d/README.md +0 -61
- data/tools/jungle/init.d/puma +0 -421
- data/tools/jungle/init.d/run-puma +0 -18
- data/tools/jungle/upstart/README.md +0 -61
- data/tools/jungle/upstart/puma-manager.conf +0 -31
- data/tools/jungle/upstart/puma.conf +0 -69
- /data/{tools → docs}/jungle/rc.d/puma.conf +0 -0
data/lib/puma/app/status.rb
CHANGED
@@ -1,73 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'puma/json_serialization'
|
3
|
+
|
1
4
|
module Puma
|
2
5
|
module App
|
6
|
+
# Check out {#call}'s source code to see what actions this web application
|
7
|
+
# can respond to.
|
3
8
|
class Status
|
4
|
-
def initialize(cli)
|
5
|
-
@cli = cli
|
6
|
-
@auth_token = nil
|
7
|
-
end
|
8
9
|
OK_STATUS = '{ "status": "ok" }'.freeze
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
def rack_response(status, body, content_type='application/json')
|
18
|
-
headers = {
|
19
|
-
'Content-Type' => content_type,
|
20
|
-
'Content-Length' => body.bytesize.to_s
|
21
|
-
}
|
22
|
-
|
23
|
-
[status, headers, [body]]
|
11
|
+
# @param launcher [::Puma::Launcher]
|
12
|
+
# @param token [String, nil] the token used for authentication
|
13
|
+
#
|
14
|
+
def initialize(launcher, token = nil)
|
15
|
+
@launcher = launcher
|
16
|
+
@auth_token = token
|
24
17
|
end
|
25
18
|
|
19
|
+
# most commands call methods in `::Puma::Launcher` based on command in
|
20
|
+
# `env['PATH_INFO']`
|
26
21
|
def call(env)
|
27
22
|
unless authenticate(env)
|
28
23
|
return rack_response(403, 'Invalid auth token', 'text/plain')
|
29
24
|
end
|
30
25
|
|
31
|
-
case
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
# resp_type is processed by following case statement, return
|
27
|
+
# is a number (status) or a string used as the body of a 200 response
|
28
|
+
resp_type =
|
29
|
+
case env['PATH_INFO'][/\/([^\/]+)$/, 1]
|
30
|
+
when 'stop'
|
31
|
+
@launcher.stop ; 200
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
return rack_response(200, OK_STATUS)
|
33
|
+
when 'halt'
|
34
|
+
@launcher.halt ; 200
|
39
35
|
|
40
|
-
|
41
|
-
|
42
|
-
return rack_response(200, OK_STATUS)
|
36
|
+
when 'restart'
|
37
|
+
@launcher.restart ; 200
|
43
38
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
39
|
+
when 'phased-restart'
|
40
|
+
@launcher.phased_restart ? 200 : 404
|
41
|
+
|
42
|
+
when 'refork'
|
43
|
+
@launcher.refork ? 200 : 404
|
44
|
+
|
45
|
+
when 'reload-worker-directory'
|
46
|
+
@launcher.send(:reload_worker_directory) ? 200 : 404
|
47
|
+
|
48
|
+
when 'gc'
|
49
|
+
GC.start ; 200
|
50
|
+
|
51
|
+
when 'gc-stats'
|
52
|
+
Puma::JSONSerialization.generate GC.stat
|
53
|
+
|
54
|
+
when 'stats'
|
55
|
+
Puma::JSONSerialization.generate @launcher.stats
|
56
|
+
|
57
|
+
when 'thread-backtraces'
|
58
|
+
backtraces = []
|
59
|
+
@launcher.thread_status do |name, backtrace|
|
60
|
+
backtraces << { name: name, backtrace: backtrace }
|
61
|
+
end
|
62
|
+
Puma::JSONSerialization.generate backtraces
|
50
63
|
|
51
|
-
when /\/reload-worker-directory$/
|
52
|
-
if !@cli.send(:reload_worker_directory)
|
53
|
-
return rack_response(404, '{ "error": "reload_worker_directory not available" }')
|
54
64
|
else
|
55
|
-
return rack_response(
|
65
|
+
return rack_response(404, "Unsupported action", 'text/plain')
|
56
66
|
end
|
57
67
|
|
58
|
-
|
59
|
-
|
60
|
-
|
68
|
+
case resp_type
|
69
|
+
when String
|
70
|
+
rack_response 200, resp_type
|
71
|
+
when 200
|
72
|
+
rack_response 200, OK_STATUS
|
73
|
+
when 404
|
74
|
+
str = env['PATH_INFO'][/\/(\S+)/, 1].tr '-', '_'
|
75
|
+
rack_response 404, "{ \"error\": \"#{str} not available\" }"
|
76
|
+
end
|
77
|
+
end
|
61
78
|
|
62
|
-
|
63
|
-
json = "{" + GC.stat.map { |k, v| "\"#{k}\": #{v}" }.join(",") + "}"
|
64
|
-
return rack_response(200, json)
|
79
|
+
private
|
65
80
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
81
|
+
def authenticate(env)
|
82
|
+
return true unless @auth_token
|
83
|
+
env['QUERY_STRING'].to_s.split(/&;/).include?("token=#{@auth_token}")
|
84
|
+
end
|
85
|
+
|
86
|
+
def rack_response(status, body, content_type='application/json')
|
87
|
+
headers = {
|
88
|
+
'Content-Type' => content_type,
|
89
|
+
'Content-Length' => body.bytesize.to_s
|
90
|
+
}
|
91
|
+
|
92
|
+
[status, headers, [body]]
|
71
93
|
end
|
72
94
|
end
|
73
95
|
end
|