puma 3.0.0.rc1 → 5.0.0.beta1
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.
Potentially problematic release.
This version of puma might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/{History.txt → History.md} +703 -70
- data/LICENSE +23 -20
- data/README.md +173 -163
- data/docs/architecture.md +37 -0
- data/{DEPLOYMENT.md → docs/deployment.md} +28 -6
- data/docs/fork_worker.md +31 -0
- 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 +13 -0
- data/docs/jungle/rc.d/README.md +74 -0
- data/docs/jungle/rc.d/puma +61 -0
- data/docs/jungle/rc.d/puma.conf +10 -0
- data/{tools → docs}/jungle/upstart/README.md +0 -0
- data/{tools → docs}/jungle/upstart/puma-manager.conf +0 -0
- data/{tools → docs}/jungle/upstart/puma.conf +1 -1
- data/docs/nginx.md +2 -2
- data/docs/plugins.md +38 -0
- data/docs/restart.md +41 -0
- data/docs/signals.md +57 -3
- data/docs/systemd.md +228 -0
- data/ext/puma_http11/PumaHttp11Service.java +2 -2
- data/ext/puma_http11/extconf.rb +16 -0
- data/ext/puma_http11/http11_parser.c +287 -468
- data/ext/puma_http11/http11_parser.h +1 -0
- data/ext/puma_http11/http11_parser.java.rl +21 -37
- data/ext/puma_http11/http11_parser.rl +10 -9
- data/ext/puma_http11/http11_parser_common.rl +4 -4
- data/ext/puma_http11/mini_ssl.c +159 -10
- data/ext/puma_http11/org/jruby/puma/Http11.java +108 -116
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +99 -132
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +30 -6
- data/ext/puma_http11/puma_http11.c +6 -38
- data/lib/puma.rb +25 -5
- data/lib/puma/accept_nonblock.rb +7 -1
- data/lib/puma/app/status.rb +53 -26
- data/lib/puma/binder.rb +150 -119
- data/lib/puma/cli.rb +56 -38
- data/lib/puma/client.rb +277 -80
- data/lib/puma/cluster.rb +326 -130
- data/lib/puma/commonlogger.rb +21 -20
- data/lib/puma/configuration.rb +160 -161
- data/lib/puma/const.rb +50 -47
- data/lib/puma/control_cli.rb +104 -63
- data/lib/puma/detect.rb +13 -1
- data/lib/puma/dsl.rb +463 -114
- data/lib/puma/events.rb +22 -13
- data/lib/puma/io_buffer.rb +9 -5
- data/lib/puma/jruby_restart.rb +2 -59
- data/lib/puma/launcher.rb +195 -105
- data/lib/puma/minissl.rb +110 -4
- data/lib/puma/minissl/context_builder.rb +76 -0
- data/lib/puma/null_io.rb +9 -14
- data/lib/puma/plugin.rb +32 -12
- data/lib/puma/plugin/tmp_restart.rb +19 -6
- data/lib/puma/rack/builder.rb +7 -5
- data/lib/puma/rack/urlmap.rb +11 -8
- data/lib/puma/rack_default.rb +2 -0
- data/lib/puma/reactor.rb +242 -32
- data/lib/puma/runner.rb +41 -30
- data/lib/puma/server.rb +265 -183
- data/lib/puma/single.rb +22 -63
- data/lib/puma/state_file.rb +9 -2
- data/lib/puma/thread_pool.rb +179 -68
- data/lib/puma/util.rb +3 -11
- data/lib/rack/handler/puma.rb +60 -11
- data/tools/Dockerfile +16 -0
- data/tools/trickletest.rb +1 -2
- metadata +35 -99
- data/COPYING +0 -55
- data/Gemfile +0 -13
- data/Manifest.txt +0 -79
- data/Rakefile +0 -158
- data/docs/config.md +0 -0
- data/ext/puma_http11/io_buffer.c +0 -155
- data/lib/puma/capistrano.rb +0 -94
- data/lib/puma/compat.rb +0 -18
- 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_18.rb +0 -56
- data/lib/puma/rack/backports/uri/common_192.rb +0 -52
- data/lib/puma/rack/backports/uri/common_193.rb +0 -29
- data/lib/puma/tcp_logger.rb +0 -32
- data/puma.gemspec +0 -52
- data/tools/jungle/README.md +0 -9
- data/tools/jungle/init.d/README.md +0 -54
- data/tools/jungle/init.d/puma +0 -394
- data/tools/jungle/init.d/run-puma +0 -3
data/lib/puma/const.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
1
4
|
module Puma
|
2
5
|
class UnsupportedOption < RuntimeError
|
3
6
|
end
|
@@ -52,6 +55,8 @@ module Puma
|
|
52
55
|
415 => 'Unsupported Media Type',
|
53
56
|
416 => 'Range Not Satisfiable',
|
54
57
|
417 => 'Expectation Failed',
|
58
|
+
418 => 'I\'m A Teapot',
|
59
|
+
421 => 'Misdirected Request',
|
55
60
|
422 => 'Unprocessable Entity',
|
56
61
|
423 => 'Locked',
|
57
62
|
424 => 'Failed Dependency',
|
@@ -59,6 +64,7 @@ module Puma
|
|
59
64
|
428 => 'Precondition Required',
|
60
65
|
429 => 'Too Many Requests',
|
61
66
|
431 => 'Request Header Fields Too Large',
|
67
|
+
451 => 'Unavailable For Legal Reasons',
|
62
68
|
500 => 'Internal Server Error',
|
63
69
|
501 => 'Not Implemented',
|
64
70
|
502 => 'Bad Gateway',
|
@@ -72,19 +78,14 @@ module Puma
|
|
72
78
|
511 => 'Network Authentication Required'
|
73
79
|
}
|
74
80
|
|
75
|
-
SYMBOL_TO_STATUS_CODE = Hash[*HTTP_STATUS_CODES.map { |code, message|
|
76
|
-
[message.downcase.gsub(/\s|-|'/, '_').to_sym, code]
|
77
|
-
}.flatten]
|
78
|
-
|
79
81
|
# For some HTTP status codes the client only expects headers.
|
80
82
|
#
|
81
83
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
STATUS_WITH_NO_ENTITY_BODY = no_body
|
84
|
+
STATUS_WITH_NO_ENTITY_BODY = {
|
85
|
+
204 => true,
|
86
|
+
205 => true,
|
87
|
+
304 => true
|
88
|
+
}
|
88
89
|
|
89
90
|
# Frequently used constants when constructing requests or responses. Many times
|
90
91
|
# the constant just refers to a string with the same contents. Using these constants
|
@@ -99,8 +100,9 @@ module Puma
|
|
99
100
|
# too taxing on performance.
|
100
101
|
module Const
|
101
102
|
|
102
|
-
PUMA_VERSION = VERSION = "
|
103
|
-
CODE_NAME = "
|
103
|
+
PUMA_VERSION = VERSION = "5.0.0.beta1".freeze
|
104
|
+
CODE_NAME = "Spoony Bard".freeze
|
105
|
+
PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
|
104
106
|
|
105
107
|
FAST_TRACK_KA_TIMEOUT = 0.2
|
106
108
|
|
@@ -116,34 +118,35 @@ module Puma
|
|
116
118
|
# sending data back
|
117
119
|
WRITE_TIMEOUT = 10
|
118
120
|
|
119
|
-
|
120
|
-
|
121
|
-
|
121
|
+
# How many requests to attempt inline before sending a client back to
|
122
|
+
# the reactor to be subject to normal ordering. The idea here is that
|
123
|
+
# we amortize the cost of going back to the reactor for a well behaved
|
124
|
+
# but very "greedy" client across 10 requests. This prevents a not
|
125
|
+
# well behaved client from monopolizing the thread forever.
|
126
|
+
MAX_FAST_INLINE = 10
|
122
127
|
|
123
128
|
# The original URI requested by the client.
|
124
129
|
REQUEST_URI= 'REQUEST_URI'.freeze
|
125
130
|
REQUEST_PATH = 'REQUEST_PATH'.freeze
|
131
|
+
QUERY_STRING = 'QUERY_STRING'.freeze
|
132
|
+
CONTENT_LENGTH = "CONTENT_LENGTH".freeze
|
126
133
|
|
127
134
|
PATH_INFO = 'PATH_INFO'.freeze
|
128
135
|
|
129
136
|
PUMA_TMP_BASE = "puma".freeze
|
130
137
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
ERROR_500_RESPONSE = "HTTP/1.1 500 Internal Server Error\r\n\r\n".freeze
|
144
|
-
|
145
|
-
# A common header for indicating the server is too busy. Not used yet.
|
146
|
-
ERROR_503_RESPONSE = "HTTP/1.1 503 Service Unavailable\r\n\r\nBUSY".freeze
|
138
|
+
ERROR_RESPONSE = {
|
139
|
+
# Indicate that we couldn't parse the request
|
140
|
+
400 => "HTTP/1.1 400 Bad Request\r\n\r\n".freeze,
|
141
|
+
# The standard empty 404 response for bad requests. Use Error4040Handler for custom stuff.
|
142
|
+
404 => "HTTP/1.1 404 Not Found\r\nConnection: close\r\nServer: Puma #{PUMA_VERSION}\r\n\r\nNOT FOUND".freeze,
|
143
|
+
# The standard empty 408 response for requests that timed out.
|
144
|
+
408 => "HTTP/1.1 408 Request Timeout\r\nConnection: close\r\nServer: Puma #{PUMA_VERSION}\r\n\r\n".freeze,
|
145
|
+
# Indicate that there was an internal error, obviously.
|
146
|
+
500 => "HTTP/1.1 500 Internal Server Error\r\n\r\n".freeze,
|
147
|
+
# A common header for indicating the server is too busy. Not used yet.
|
148
|
+
503 => "HTTP/1.1 503 Service Unavailable\r\n\r\nBUSY".freeze
|
149
|
+
}
|
147
150
|
|
148
151
|
# The basic max request size we'll try to read.
|
149
152
|
CHUNK_SIZE = 16 * 1024
|
@@ -155,26 +158,15 @@ module Puma
|
|
155
158
|
# Maximum request body size before it is moved out of memory and into a tempfile for reading.
|
156
159
|
MAX_BODY = MAX_HEADER
|
157
160
|
|
158
|
-
# A frozen format for this is about 15% faster
|
159
|
-
STATUS_FORMAT = "HTTP/1.1 %d %s\r\nConnection: close\r\n".freeze
|
160
|
-
|
161
|
-
CONTENT_TYPE = "Content-Type".freeze
|
162
|
-
|
163
|
-
LAST_MODIFIED = "Last-Modified".freeze
|
164
|
-
ETAG = "ETag".freeze
|
165
|
-
SLASH = "/".freeze
|
166
161
|
REQUEST_METHOD = "REQUEST_METHOD".freeze
|
167
|
-
GET = "GET".freeze
|
168
162
|
HEAD = "HEAD".freeze
|
169
163
|
# ETag is based on the apache standard of hex mtime-size-inode (inode is 0 on win32)
|
170
|
-
ETAG_FORMAT = "\"%x-%x-%x\"".freeze
|
171
164
|
LINE_END = "\r\n".freeze
|
172
165
|
REMOTE_ADDR = "REMOTE_ADDR".freeze
|
173
166
|
HTTP_X_FORWARDED_FOR = "HTTP_X_FORWARDED_FOR".freeze
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
HOST = "HOST".freeze
|
167
|
+
HTTP_X_FORWARDED_SSL = "HTTP_X_FORWARDED_SSL".freeze
|
168
|
+
HTTP_X_FORWARDED_SCHEME = "HTTP_X_FORWARDED_SCHEME".freeze
|
169
|
+
HTTP_X_FORWARDED_PROTO = "HTTP_X_FORWARDED_PROTO".freeze
|
178
170
|
|
179
171
|
SERVER_NAME = "SERVER_NAME".freeze
|
180
172
|
SERVER_PORT = "SERVER_PORT".freeze
|
@@ -183,11 +175,9 @@ module Puma
|
|
183
175
|
PORT_443 = "443".freeze
|
184
176
|
LOCALHOST = "localhost".freeze
|
185
177
|
LOCALHOST_IP = "127.0.0.1".freeze
|
186
|
-
LOCALHOST_ADDR = "127.0.0.1:0".freeze
|
187
178
|
|
188
179
|
SERVER_PROTOCOL = "SERVER_PROTOCOL".freeze
|
189
180
|
HTTP_11 = "HTTP/1.1".freeze
|
190
|
-
HTTP_10 = "HTTP/1.0".freeze
|
191
181
|
|
192
182
|
SERVER_SOFTWARE = "SERVER_SOFTWARE".freeze
|
193
183
|
GATEWAY_INTERFACE = "GATEWAY_INTERFACE".freeze
|
@@ -211,7 +201,10 @@ module Puma
|
|
211
201
|
|
212
202
|
HTTP_VERSION = "HTTP_VERSION".freeze
|
213
203
|
HTTP_CONNECTION = "HTTP_CONNECTION".freeze
|
204
|
+
HTTP_EXPECT = "HTTP_EXPECT".freeze
|
205
|
+
CONTINUE = "100-continue".freeze
|
214
206
|
|
207
|
+
HTTP_11_100 = "HTTP/1.1 100 Continue\r\n\r\n".freeze
|
215
208
|
HTTP_11_200 = "HTTP/1.1 200 OK\r\n".freeze
|
216
209
|
HTTP_10_200 = "HTTP/1.0 200 OK\r\n".freeze
|
217
210
|
|
@@ -221,6 +214,7 @@ module Puma
|
|
221
214
|
CONTENT_LENGTH2 = "content-length".freeze
|
222
215
|
CONTENT_LENGTH_S = "Content-Length: ".freeze
|
223
216
|
TRANSFER_ENCODING = "transfer-encoding".freeze
|
217
|
+
TRANSFER_ENCODING2 = "HTTP_TRANSFER_ENCODING".freeze
|
224
218
|
|
225
219
|
CONNECTION_CLOSE = "Connection: close\r\n".freeze
|
226
220
|
CONNECTION_KEEP_ALIVE = "Connection: Keep-Alive\r\n".freeze
|
@@ -228,12 +222,21 @@ module Puma
|
|
228
222
|
TRANSFER_ENCODING_CHUNKED = "Transfer-Encoding: chunked\r\n".freeze
|
229
223
|
CLOSE_CHUNKED = "0\r\n\r\n".freeze
|
230
224
|
|
225
|
+
CHUNKED = "chunked".freeze
|
226
|
+
|
231
227
|
COLON = ": ".freeze
|
232
228
|
|
233
229
|
NEWLINE = "\n".freeze
|
230
|
+
HTTP_INJECTION_REGEX = /[\r\n]/.freeze
|
234
231
|
|
235
232
|
HIJACK_P = "rack.hijack?".freeze
|
236
233
|
HIJACK = "rack.hijack".freeze
|
237
234
|
HIJACK_IO = "rack.hijack_io".freeze
|
235
|
+
|
236
|
+
EARLY_HINTS = "rack.early_hints".freeze
|
237
|
+
|
238
|
+
# Mininum interval to checks worker health
|
239
|
+
WORKER_CHECK_INTERVAL = 5
|
240
|
+
|
238
241
|
end
|
239
242
|
end
|
data/lib/puma/control_cli.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'optparse'
|
2
|
-
|
3
|
-
|
4
|
-
|
4
|
+
require_relative 'state_file'
|
5
|
+
require_relative 'const'
|
6
|
+
require_relative 'detect'
|
7
|
+
require_relative 'configuration'
|
5
8
|
require 'uri'
|
6
9
|
require 'socket'
|
10
|
+
|
7
11
|
module Puma
|
8
12
|
class ControlCLI
|
9
13
|
|
10
|
-
COMMANDS = %w{halt restart phased-restart start stats status stop reload-worker-directory}
|
14
|
+
COMMANDS = %w{halt restart phased-restart start stats status stop reload-worker-directory gc gc-stats thread-backtraces refork}
|
15
|
+
PRINTABLE_COMMANDS = %w{gc-stats stats thread-backtraces}
|
11
16
|
|
12
17
|
def initialize(argv, stdout=STDOUT, stderr=STDERR)
|
13
18
|
@state = nil
|
@@ -18,6 +23,7 @@ module Puma
|
|
18
23
|
@control_auth_token = nil
|
19
24
|
@config_file = nil
|
20
25
|
@command = nil
|
26
|
+
@environment = ENV['RACK_ENV'] || ENV['RAILS_ENV']
|
21
27
|
|
22
28
|
@argv = argv.dup
|
23
29
|
@stdout = stdout
|
@@ -55,6 +61,11 @@ module Puma
|
|
55
61
|
@config_file = arg
|
56
62
|
end
|
57
63
|
|
64
|
+
o.on "-e", "--environment ENVIRONMENT",
|
65
|
+
"The environment to run the Rack app on (default development)" do |arg|
|
66
|
+
@environment = arg
|
67
|
+
end
|
68
|
+
|
58
69
|
o.on_tail("-H", "--help", "Show this message") do
|
59
70
|
@stdout.puts o
|
60
71
|
exit
|
@@ -67,24 +78,11 @@ module Puma
|
|
67
78
|
end
|
68
79
|
|
69
80
|
opts.order!(argv) { |a| opts.terminate a }
|
81
|
+
opts.parse!
|
70
82
|
|
71
83
|
@command = argv.shift
|
72
84
|
|
73
|
-
|
74
|
-
if @config_file.nil? and File.exist?('config/puma.rb')
|
75
|
-
@config_file = 'config/puma.rb'
|
76
|
-
end
|
77
|
-
|
78
|
-
if @config_file
|
79
|
-
config = Puma::Configuration.from_file @config_file
|
80
|
-
@state ||= config.options[:state]
|
81
|
-
@control_url ||= config.options[:control_url]
|
82
|
-
@control_auth_token ||= config.options[:control_auth_token]
|
83
|
-
@pidfile ||= config.options[:pidfile]
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
# check present of command
|
85
|
+
# check presence of command
|
88
86
|
unless @command
|
89
87
|
raise "Available commands: #{COMMANDS.join(", ")}"
|
90
88
|
end
|
@@ -93,6 +91,24 @@ module Puma
|
|
93
91
|
raise "Invalid command: #{@command}"
|
94
92
|
end
|
95
93
|
|
94
|
+
unless @config_file == '-'
|
95
|
+
environment = @environment || 'development'
|
96
|
+
|
97
|
+
if @config_file.nil?
|
98
|
+
@config_file = %W(config/puma/#{environment}.rb config/puma.rb).find do |f|
|
99
|
+
File.exist?(f)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
if @config_file
|
104
|
+
config = Puma::Configuration.new({ config_files: [@config_file] }, {})
|
105
|
+
config.load
|
106
|
+
@state ||= config.options[:state]
|
107
|
+
@control_url ||= config.options[:control_url]
|
108
|
+
@control_auth_token ||= config.options[:control_auth_token]
|
109
|
+
@pidfile ||= config.options[:pidfile]
|
110
|
+
end
|
111
|
+
end
|
96
112
|
rescue => e
|
97
113
|
@stdout.puts e.message
|
98
114
|
exit 1
|
@@ -108,7 +124,7 @@ module Puma
|
|
108
124
|
raise "State file not found: #{@state}"
|
109
125
|
end
|
110
126
|
|
111
|
-
sf = StateFile.new
|
127
|
+
sf = Puma::StateFile.new
|
112
128
|
sf.load @state
|
113
129
|
|
114
130
|
@control_url = sf.control_url
|
@@ -116,7 +132,7 @@ module Puma
|
|
116
132
|
@pid = sf.pid
|
117
133
|
elsif @pidfile
|
118
134
|
# get pid from pid_file
|
119
|
-
|
135
|
+
File.open(@pidfile) { |f| @pid = f.read.to_i }
|
120
136
|
end
|
121
137
|
end
|
122
138
|
|
@@ -124,7 +140,14 @@ module Puma
|
|
124
140
|
uri = URI.parse @control_url
|
125
141
|
|
126
142
|
# create server object by scheme
|
127
|
-
|
143
|
+
server = case uri.scheme
|
144
|
+
when "ssl"
|
145
|
+
require 'openssl'
|
146
|
+
OpenSSL::SSL::SSLSocket.new(
|
147
|
+
TCPSocket.new(uri.host, uri.port),
|
148
|
+
OpenSSL::SSL::SSLContext.new)
|
149
|
+
.tap { |ssl| ssl.sync_close = true } # default is false
|
150
|
+
.tap(&:connect)
|
128
151
|
when "tcp"
|
129
152
|
TCPSocket.new uri.host, uri.port
|
130
153
|
when "unix"
|
@@ -142,9 +165,9 @@ module Puma
|
|
142
165
|
url = url + "?token=#{@control_auth_token}"
|
143
166
|
end
|
144
167
|
|
145
|
-
|
168
|
+
server << "GET #{url} HTTP/1.0\r\n\r\n"
|
146
169
|
|
147
|
-
unless data =
|
170
|
+
unless data = server.read
|
148
171
|
raise "Server closed connection before responding"
|
149
172
|
end
|
150
173
|
|
@@ -165,10 +188,16 @@ module Puma
|
|
165
188
|
end
|
166
189
|
|
167
190
|
message "Command #{@command} sent success"
|
168
|
-
message response.last if @command
|
191
|
+
message response.last if PRINTABLE_COMMANDS.include?(@command)
|
192
|
+
end
|
193
|
+
ensure
|
194
|
+
if server
|
195
|
+
if uri.scheme == "ssl"
|
196
|
+
server.sysclose
|
197
|
+
else
|
198
|
+
server.close unless server.closed?
|
199
|
+
end
|
169
200
|
end
|
170
|
-
|
171
|
-
@server.close
|
172
201
|
end
|
173
202
|
|
174
203
|
def send_signal
|
@@ -177,46 +206,58 @@ module Puma
|
|
177
206
|
end
|
178
207
|
|
179
208
|
begin
|
180
|
-
Process.getpgid pid
|
181
|
-
rescue SystemCallError
|
182
|
-
if @command == "restart"
|
183
|
-
start
|
184
|
-
else
|
185
|
-
raise "No pid '#{pid}' found"
|
186
|
-
end
|
187
|
-
end
|
188
209
|
|
189
|
-
|
190
|
-
|
191
|
-
|
210
|
+
case @command
|
211
|
+
when "restart"
|
212
|
+
Process.kill "SIGUSR2", @pid
|
192
213
|
|
193
|
-
|
194
|
-
|
214
|
+
when "halt"
|
215
|
+
Process.kill "QUIT", @pid
|
195
216
|
|
196
|
-
|
197
|
-
|
217
|
+
when "stop"
|
218
|
+
Process.kill "SIGTERM", @pid
|
198
219
|
|
199
|
-
|
200
|
-
|
201
|
-
|
220
|
+
when "stats"
|
221
|
+
puts "Stats not available via pid only"
|
222
|
+
return
|
202
223
|
|
203
|
-
|
204
|
-
|
205
|
-
|
224
|
+
when "reload-worker-directory"
|
225
|
+
puts "reload-worker-directory not available via pid only"
|
226
|
+
return
|
206
227
|
|
207
|
-
|
208
|
-
|
228
|
+
when "phased-restart"
|
229
|
+
Process.kill "SIGUSR1", @pid
|
209
230
|
|
210
|
-
|
211
|
-
|
212
|
-
|
231
|
+
when "status"
|
232
|
+
begin
|
233
|
+
Process.kill 0, @pid
|
234
|
+
puts "Puma is started"
|
235
|
+
rescue Errno::ESRCH
|
236
|
+
raise "Puma is not running"
|
237
|
+
end
|
238
|
+
|
239
|
+
return
|
240
|
+
|
241
|
+
when "refork"
|
242
|
+
Process.kill "SIGURG", @pid
|
243
|
+
|
244
|
+
else
|
245
|
+
return
|
246
|
+
end
|
247
|
+
|
248
|
+
rescue SystemCallError
|
249
|
+
if @command == "restart"
|
250
|
+
start
|
251
|
+
else
|
252
|
+
raise "No pid '#{@pid}' found"
|
253
|
+
end
|
213
254
|
end
|
214
255
|
|
215
256
|
message "Command #{@command} sent success"
|
216
257
|
end
|
217
258
|
|
218
259
|
def run
|
219
|
-
start if @command == "start"
|
260
|
+
return start if @command == "start"
|
220
261
|
|
221
262
|
prepare_configuration
|
222
263
|
|
@@ -231,19 +272,19 @@ module Puma
|
|
231
272
|
exit 1
|
232
273
|
end
|
233
274
|
|
234
|
-
|
275
|
+
private
|
235
276
|
def start
|
236
277
|
require 'puma/cli'
|
237
278
|
|
238
|
-
run_args =
|
279
|
+
run_args = []
|
239
280
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
281
|
+
run_args += ["-S", @state] if @state
|
282
|
+
run_args += ["-q"] if @quiet
|
283
|
+
run_args += ["--pidfile", @pidfile] if @pidfile
|
284
|
+
run_args += ["--control-url", @control_url] if @control_url
|
285
|
+
run_args += ["--control-token", @control_auth_token] if @control_auth_token
|
286
|
+
run_args += ["-C", @config_file] if @config_file
|
287
|
+
run_args += ["-e", @environment] if @environment
|
247
288
|
|
248
289
|
events = Puma::Events.new @stdout, @stderr
|
249
290
|
|