mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Simplify Runner#start_control URL parsing (#2111)
* Simplify Runner#start_control URL parsing Reuse logic from Binder#parse. * Parameterize log message
This commit is contained in:
parent
4f8a85f421
commit
a948c165ae
3 changed files with 5 additions and 24 deletions
|
@ -17,6 +17,7 @@
|
|||
* Refactor
|
||||
* Remove unused loader argument from Plugin initializer (#2095)
|
||||
* Simplify `Configuration.random_token` and remove insecure fallback (#2102)
|
||||
* Simplify `Runner#start_control` URL parsing (#2111)
|
||||
|
||||
## 4.3.1 and 3.12.2 / 2019-12-05
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ module Puma
|
|||
end
|
||||
end
|
||||
|
||||
def parse(binds, logger)
|
||||
def parse(binds, logger, log_msg = 'Listening')
|
||||
binds.each do |str|
|
||||
uri = URI.parse str
|
||||
case uri.scheme
|
||||
|
@ -113,7 +113,7 @@ module Puma
|
|||
i.local_address.ip_unpack.join(':')
|
||||
end
|
||||
|
||||
logger.log "* Listening on tcp://#{addr}"
|
||||
logger.log "* #{log_msg} on tcp://#{addr}"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -149,7 +149,7 @@ module Puma
|
|||
end
|
||||
|
||||
io = add_unix_listener path, umask, mode, backlog
|
||||
logger.log "* Listening on #{str}"
|
||||
logger.log "* #{log_msg} on #{str}"
|
||||
end
|
||||
|
||||
@listeners << [str, io]
|
||||
|
|
|
@ -52,8 +52,6 @@ module Puma
|
|||
|
||||
require 'puma/app/status'
|
||||
|
||||
uri = URI.parse str
|
||||
|
||||
if token = @options[:control_auth_token]
|
||||
token = nil if token.empty? || token == 'none'
|
||||
end
|
||||
|
@ -64,25 +62,7 @@ module Puma
|
|||
control.min_threads = 0
|
||||
control.max_threads = 1
|
||||
|
||||
case uri.scheme
|
||||
when "ssl"
|
||||
log "* Starting control server on #{str}"
|
||||
params = Util.parse_query uri.query
|
||||
ctx = MiniSSL::ContextBuilder.new(params, @events).context
|
||||
|
||||
control.add_ssl_listener uri.host, uri.port, ctx
|
||||
when "tcp"
|
||||
log "* Starting control server on #{str}"
|
||||
control.add_tcp_listener uri.host, uri.port
|
||||
when "unix"
|
||||
log "* Starting control server on #{str}"
|
||||
path = "#{uri.host}#{uri.path}"
|
||||
mask = @options[:control_url_umask]
|
||||
|
||||
control.add_unix_listener path, mask
|
||||
else
|
||||
error "Invalid control URI: #{str}"
|
||||
end
|
||||
control.binder.parse [str], self, 'Starting control server'
|
||||
|
||||
control.run
|
||||
@control = control
|
||||
|
|
Loading…
Add table
Reference in a new issue