jun-puma 1.0.1-java → 1.0.2-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/puma/puma_http11.jar +0 -0
- metadata +3 -81
- data/bin/puma-wild +0 -25
- data/docs/architecture.md +0 -74
- data/docs/compile_options.md +0 -55
- data/docs/deployment.md +0 -102
- data/docs/fork_worker.md +0 -31
- data/docs/images/puma-connection-flow-no-reactor.png +0 -0
- data/docs/images/puma-connection-flow.png +0 -0
- data/docs/images/puma-general-arch.png +0 -0
- data/docs/jungle/README.md +0 -9
- data/docs/jungle/rc.d/README.md +0 -74
- data/docs/jungle/rc.d/puma +0 -61
- data/docs/jungle/rc.d/puma.conf +0 -10
- data/docs/kubernetes.md +0 -78
- data/docs/nginx.md +0 -80
- data/docs/plugins.md +0 -38
- data/docs/rails_dev_mode.md +0 -28
- data/docs/restart.md +0 -64
- data/docs/signals.md +0 -98
- data/docs/stats.md +0 -142
- data/docs/systemd.md +0 -244
- data/docs/testing_benchmarks_local_files.md +0 -150
- data/docs/testing_test_rackup_ci_files.md +0 -36
- data/ext/puma_http11/PumaHttp11Service.java +0 -17
- data/ext/puma_http11/ext_help.h +0 -15
- data/ext/puma_http11/http11_parser.c +0 -1057
- data/ext/puma_http11/http11_parser.h +0 -65
- data/ext/puma_http11/http11_parser.java.rl +0 -145
- data/ext/puma_http11/http11_parser.rl +0 -149
- data/ext/puma_http11/http11_parser_common.rl +0 -54
- data/ext/puma_http11/mini_ssl.c +0 -832
- data/ext/puma_http11/no_ssl/PumaHttp11Service.java +0 -15
- data/ext/puma_http11/org/jruby/puma/Http11.java +0 -226
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +0 -455
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +0 -508
- data/ext/puma_http11/puma_http11.c +0 -492
- data/lib/puma/app/status.rb +0 -96
- data/lib/puma/binder.rb +0 -501
- data/lib/puma/cli.rb +0 -243
- data/lib/puma/client.rb +0 -632
- data/lib/puma/cluster/worker.rb +0 -182
- data/lib/puma/cluster/worker_handle.rb +0 -97
- data/lib/puma/cluster.rb +0 -562
- data/lib/puma/commonlogger.rb +0 -115
- data/lib/puma/configuration.rb +0 -391
- data/lib/puma/const.rb +0 -289
- data/lib/puma/control_cli.rb +0 -316
- data/lib/puma/detect.rb +0 -45
- data/lib/puma/dsl.rb +0 -1204
- data/lib/puma/error_logger.rb +0 -113
- data/lib/puma/events.rb +0 -57
- data/lib/puma/io_buffer.rb +0 -46
- data/lib/puma/jruby_restart.rb +0 -27
- data/lib/puma/json_serialization.rb +0 -96
- data/lib/puma/launcher/bundle_pruner.rb +0 -104
- data/lib/puma/launcher.rb +0 -484
- data/lib/puma/log_writer.rb +0 -147
- data/lib/puma/minissl/context_builder.rb +0 -95
- data/lib/puma/minissl.rb +0 -458
- data/lib/puma/null_io.rb +0 -61
- data/lib/puma/plugin/systemd.rb +0 -90
- data/lib/puma/plugin/tmp_restart.rb +0 -36
- data/lib/puma/plugin.rb +0 -111
- data/lib/puma/rack/builder.rb +0 -297
- data/lib/puma/rack/urlmap.rb +0 -93
- data/lib/puma/rack_default.rb +0 -24
- data/lib/puma/reactor.rb +0 -125
- data/lib/puma/request.rb +0 -671
- data/lib/puma/runner.rb +0 -213
- data/lib/puma/sd_notify.rb +0 -149
- data/lib/puma/server.rb +0 -664
- data/lib/puma/single.rb +0 -69
- data/lib/puma/state_file.rb +0 -68
- data/lib/puma/thread_pool.rb +0 -434
- data/lib/puma/util.rb +0 -141
- data/lib/puma.rb +0 -78
- data/lib/rack/handler/puma.rb +0 -141
- data/tools/Dockerfile +0 -16
- data/tools/trickletest.rb +0 -44
data/lib/puma/control_cli.rb
DELETED
@@ -1,316 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'optparse'
|
4
|
-
require_relative 'const'
|
5
|
-
require_relative 'detect'
|
6
|
-
require 'uri'
|
7
|
-
require 'socket'
|
8
|
-
|
9
|
-
module Puma
|
10
|
-
class ControlCLI
|
11
|
-
|
12
|
-
# values must be string or nil
|
13
|
-
# value of `nil` means command cannot be processed via signal
|
14
|
-
# @version 5.0.3
|
15
|
-
CMD_PATH_SIG_MAP = {
|
16
|
-
'gc' => nil,
|
17
|
-
'gc-stats' => nil,
|
18
|
-
'halt' => 'SIGQUIT',
|
19
|
-
'info' => 'SIGINFO',
|
20
|
-
'phased-restart' => 'SIGUSR1',
|
21
|
-
'refork' => 'SIGURG',
|
22
|
-
'reload-worker-directory' => nil,
|
23
|
-
'reopen-log' => 'SIGHUP',
|
24
|
-
'restart' => 'SIGUSR2',
|
25
|
-
'start' => nil,
|
26
|
-
'stats' => nil,
|
27
|
-
'status' => '',
|
28
|
-
'stop' => 'SIGTERM',
|
29
|
-
'thread-backtraces' => nil,
|
30
|
-
'worker-count-down' => 'SIGTTOU',
|
31
|
-
'worker-count-up' => 'SIGTTIN'
|
32
|
-
}.freeze
|
33
|
-
|
34
|
-
# commands that cannot be used in a request
|
35
|
-
NO_REQ_COMMANDS = %w[info reopen-log worker-count-down worker-count-up].freeze
|
36
|
-
|
37
|
-
# @version 5.0.0
|
38
|
-
PRINTABLE_COMMANDS = %w[gc-stats stats thread-backtraces].freeze
|
39
|
-
|
40
|
-
def initialize(argv, stdout=STDOUT, stderr=STDERR)
|
41
|
-
@state = nil
|
42
|
-
@quiet = false
|
43
|
-
@pidfile = nil
|
44
|
-
@pid = nil
|
45
|
-
@control_url = nil
|
46
|
-
@control_auth_token = nil
|
47
|
-
@config_file = nil
|
48
|
-
@command = nil
|
49
|
-
@environment = ENV['APP_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']
|
50
|
-
|
51
|
-
@argv = argv.dup
|
52
|
-
@stdout = stdout
|
53
|
-
@stderr = stderr
|
54
|
-
@cli_options = {}
|
55
|
-
|
56
|
-
opts = OptionParser.new do |o|
|
57
|
-
o.banner = "Usage: pumactl (-p PID | -P pidfile | -S status_file | -C url -T token | -F config.rb) (#{CMD_PATH_SIG_MAP.keys.join("|")})"
|
58
|
-
|
59
|
-
o.on "-S", "--state PATH", "Where the state file to use is" do |arg|
|
60
|
-
@state = arg
|
61
|
-
end
|
62
|
-
|
63
|
-
o.on "-Q", "--quiet", "Not display messages" do |arg|
|
64
|
-
@quiet = true
|
65
|
-
end
|
66
|
-
|
67
|
-
o.on "-P", "--pidfile PATH", "Pid file" do |arg|
|
68
|
-
@pidfile = arg
|
69
|
-
end
|
70
|
-
|
71
|
-
o.on "-p", "--pid PID", "Pid" do |arg|
|
72
|
-
@pid = arg.to_i
|
73
|
-
end
|
74
|
-
|
75
|
-
o.on "-C", "--control-url URL", "The bind url to use for the control server" do |arg|
|
76
|
-
@control_url = arg
|
77
|
-
end
|
78
|
-
|
79
|
-
o.on "-T", "--control-token TOKEN", "The token to use as authentication for the control server" do |arg|
|
80
|
-
@control_auth_token = arg
|
81
|
-
end
|
82
|
-
|
83
|
-
o.on "-F", "--config-file PATH", "Puma config script" do |arg|
|
84
|
-
@config_file = arg
|
85
|
-
end
|
86
|
-
|
87
|
-
o.on "-e", "--environment ENVIRONMENT",
|
88
|
-
"The environment to run the Rack app on (default development)" do |arg|
|
89
|
-
@environment = arg
|
90
|
-
end
|
91
|
-
|
92
|
-
o.on_tail("-H", "--help", "Show this message") do
|
93
|
-
@stdout.puts o
|
94
|
-
exit
|
95
|
-
end
|
96
|
-
|
97
|
-
o.on_tail("-V", "--version", "Show version") do
|
98
|
-
@stdout.puts Const::PUMA_VERSION
|
99
|
-
exit
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
opts.order!(argv) { |a| opts.terminate a }
|
104
|
-
opts.parse!
|
105
|
-
|
106
|
-
@command = argv.shift
|
107
|
-
|
108
|
-
# check presence of command
|
109
|
-
unless @command
|
110
|
-
raise "Available commands: #{CMD_PATH_SIG_MAP.keys.join(", ")}"
|
111
|
-
end
|
112
|
-
|
113
|
-
unless CMD_PATH_SIG_MAP.key? @command
|
114
|
-
raise "Invalid command: #{@command}"
|
115
|
-
end
|
116
|
-
|
117
|
-
unless @config_file == '-'
|
118
|
-
environment = @environment || 'development'
|
119
|
-
|
120
|
-
if @config_file.nil?
|
121
|
-
@config_file = %W(config/puma/#{environment}.rb config/puma.rb).find do |f|
|
122
|
-
File.exist?(f)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
if @config_file
|
127
|
-
require_relative 'configuration'
|
128
|
-
require_relative 'log_writer'
|
129
|
-
|
130
|
-
config = Puma::Configuration.new({ config_files: [@config_file] }, {})
|
131
|
-
config.load
|
132
|
-
@state ||= config.options[:state]
|
133
|
-
@control_url ||= config.options[:control_url]
|
134
|
-
@control_auth_token ||= config.options[:control_auth_token]
|
135
|
-
@pidfile ||= config.options[:pidfile]
|
136
|
-
end
|
137
|
-
end
|
138
|
-
rescue => e
|
139
|
-
@stdout.puts e.message
|
140
|
-
exit 1
|
141
|
-
end
|
142
|
-
|
143
|
-
def message(msg)
|
144
|
-
@stdout.puts msg unless @quiet
|
145
|
-
end
|
146
|
-
|
147
|
-
def prepare_configuration
|
148
|
-
if @state
|
149
|
-
unless File.exist? @state
|
150
|
-
raise "State file not found: #{@state}"
|
151
|
-
end
|
152
|
-
|
153
|
-
require_relative 'state_file'
|
154
|
-
|
155
|
-
sf = Puma::StateFile.new
|
156
|
-
sf.load @state
|
157
|
-
|
158
|
-
@control_url = sf.control_url
|
159
|
-
@control_auth_token = sf.control_auth_token
|
160
|
-
@pid = sf.pid
|
161
|
-
elsif @pidfile
|
162
|
-
# get pid from pid_file
|
163
|
-
@pid = File.read(@pidfile, mode: 'rb:UTF-8').to_i
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def send_request
|
168
|
-
uri = URI.parse @control_url
|
169
|
-
|
170
|
-
host = uri.host
|
171
|
-
|
172
|
-
# create server object by scheme
|
173
|
-
server =
|
174
|
-
case uri.scheme
|
175
|
-
when 'ssl'
|
176
|
-
require 'openssl'
|
177
|
-
host = host[1..-2] if host&.start_with? '['
|
178
|
-
OpenSSL::SSL::SSLSocket.new(
|
179
|
-
TCPSocket.new(host, uri.port),
|
180
|
-
OpenSSL::SSL::SSLContext.new)
|
181
|
-
.tap { |ssl| ssl.sync_close = true } # default is false
|
182
|
-
.tap(&:connect)
|
183
|
-
when 'tcp'
|
184
|
-
host = host[1..-2] if host&.start_with? '['
|
185
|
-
TCPSocket.new host, uri.port
|
186
|
-
when 'unix'
|
187
|
-
# check for abstract UNIXSocket
|
188
|
-
UNIXSocket.new(@control_url.start_with?('unix://@') ?
|
189
|
-
"\0#{host}#{uri.path}" : "#{host}#{uri.path}")
|
190
|
-
else
|
191
|
-
raise "Invalid scheme: #{uri.scheme}"
|
192
|
-
end
|
193
|
-
|
194
|
-
if @command == 'status'
|
195
|
-
message 'Puma is started'
|
196
|
-
else
|
197
|
-
url = "/#{@command}"
|
198
|
-
|
199
|
-
if @control_auth_token
|
200
|
-
url = url + "?token=#{@control_auth_token}"
|
201
|
-
end
|
202
|
-
|
203
|
-
server.syswrite "GET #{url} HTTP/1.0\r\n\r\n"
|
204
|
-
|
205
|
-
unless data = server.read
|
206
|
-
raise 'Server closed connection before responding'
|
207
|
-
end
|
208
|
-
|
209
|
-
response = data.split("\r\n")
|
210
|
-
|
211
|
-
if response.empty?
|
212
|
-
raise "Server sent empty response"
|
213
|
-
end
|
214
|
-
|
215
|
-
@http, @code, @message = response.first.split(' ',3)
|
216
|
-
|
217
|
-
if @code == '403'
|
218
|
-
raise 'Unauthorized access to server (wrong auth token)'
|
219
|
-
elsif @code == '404'
|
220
|
-
raise "Command error: #{response.last}"
|
221
|
-
elsif @code != '200'
|
222
|
-
raise "Bad response from server: #{@code}"
|
223
|
-
end
|
224
|
-
|
225
|
-
message "Command #{@command} sent success"
|
226
|
-
message response.last if PRINTABLE_COMMANDS.include?(@command)
|
227
|
-
end
|
228
|
-
ensure
|
229
|
-
if server
|
230
|
-
if uri.scheme == 'ssl'
|
231
|
-
server.sysclose
|
232
|
-
else
|
233
|
-
server.close unless server.closed?
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
def send_signal
|
239
|
-
unless @pid
|
240
|
-
raise 'Neither pid nor control url available'
|
241
|
-
end
|
242
|
-
|
243
|
-
begin
|
244
|
-
sig = CMD_PATH_SIG_MAP[@command]
|
245
|
-
|
246
|
-
if sig.nil?
|
247
|
-
@stdout.puts "'#{@command}' not available via pid only"
|
248
|
-
@stdout.flush unless @stdout.sync
|
249
|
-
return
|
250
|
-
elsif sig.start_with? 'SIG'
|
251
|
-
if Signal.list.key? sig.sub(/\ASIG/, '')
|
252
|
-
Process.kill sig, @pid
|
253
|
-
else
|
254
|
-
raise "Signal '#{sig}' not available'"
|
255
|
-
end
|
256
|
-
elsif @command == 'status'
|
257
|
-
begin
|
258
|
-
Process.kill 0, @pid
|
259
|
-
@stdout.puts 'Puma is started'
|
260
|
-
@stdout.flush unless @stdout.sync
|
261
|
-
rescue Errno::ESRCH
|
262
|
-
raise 'Puma is not running'
|
263
|
-
end
|
264
|
-
return
|
265
|
-
end
|
266
|
-
rescue SystemCallError
|
267
|
-
if @command == 'restart'
|
268
|
-
start
|
269
|
-
else
|
270
|
-
raise "No pid '#{@pid}' found"
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
message "Command #{@command} sent success"
|
275
|
-
end
|
276
|
-
|
277
|
-
def run
|
278
|
-
return start if @command == 'start'
|
279
|
-
prepare_configuration
|
280
|
-
|
281
|
-
if Puma.windows? || @control_url && !NO_REQ_COMMANDS.include?(@command)
|
282
|
-
send_request
|
283
|
-
else
|
284
|
-
send_signal
|
285
|
-
end
|
286
|
-
|
287
|
-
rescue => e
|
288
|
-
message e.message
|
289
|
-
exit 1
|
290
|
-
end
|
291
|
-
|
292
|
-
private
|
293
|
-
def start
|
294
|
-
require_relative 'cli'
|
295
|
-
|
296
|
-
run_args = []
|
297
|
-
|
298
|
-
run_args += ["-S", @state] if @state
|
299
|
-
run_args += ["-q"] if @quiet
|
300
|
-
run_args += ["--pidfile", @pidfile] if @pidfile
|
301
|
-
run_args += ["--control-url", @control_url] if @control_url
|
302
|
-
run_args += ["--control-token", @control_auth_token] if @control_auth_token
|
303
|
-
run_args += ["-C", @config_file] if @config_file
|
304
|
-
run_args += ["-e", @environment] if @environment
|
305
|
-
|
306
|
-
log_writer = Puma::LogWriter.new(@stdout, @stderr)
|
307
|
-
|
308
|
-
# replace $0 because puma use it to generate restart command
|
309
|
-
puma_cmd = $0.gsub(/pumactl$/, 'puma')
|
310
|
-
$0 = puma_cmd if File.exist?(puma_cmd)
|
311
|
-
|
312
|
-
cli = Puma::CLI.new run_args, log_writer
|
313
|
-
cli.run
|
314
|
-
end
|
315
|
-
end
|
316
|
-
end
|
data/lib/puma/detect.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# This file can be loaded independently of puma.rb, so it cannot have any code
|
4
|
-
# that assumes puma.rb is loaded.
|
5
|
-
|
6
|
-
|
7
|
-
module Puma
|
8
|
-
# @version 5.2.1
|
9
|
-
HAS_FORK = ::Process.respond_to? :fork
|
10
|
-
|
11
|
-
HAS_NATIVE_IO_WAIT = ::IO.public_instance_methods(false).include? :wait_readable
|
12
|
-
|
13
|
-
IS_JRUBY = Object.const_defined? :JRUBY_VERSION
|
14
|
-
|
15
|
-
IS_OSX = RUBY_DESCRIPTION.include? 'darwin'
|
16
|
-
|
17
|
-
IS_WINDOWS = RUBY_DESCRIPTION.match?(/mswin|ming|cygwin/)
|
18
|
-
|
19
|
-
IS_LINUX = !(IS_OSX || IS_WINDOWS)
|
20
|
-
|
21
|
-
# @version 5.2.0
|
22
|
-
IS_MRI = RUBY_ENGINE == 'ruby'
|
23
|
-
|
24
|
-
def self.jruby?
|
25
|
-
IS_JRUBY
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.osx?
|
29
|
-
IS_OSX
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.windows?
|
33
|
-
IS_WINDOWS
|
34
|
-
end
|
35
|
-
|
36
|
-
# @version 5.0.0
|
37
|
-
def self.mri?
|
38
|
-
IS_MRI
|
39
|
-
end
|
40
|
-
|
41
|
-
# @version 5.0.0
|
42
|
-
def self.forkable?
|
43
|
-
HAS_FORK
|
44
|
-
end
|
45
|
-
end
|