Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Log binding on http:// for TCP bindings to make it clickable #2300

Merged
merged 4 commits into from Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -29,6 +29,7 @@
* Daemonization has been removed without replacement. (#2170)
* Changed #connected_port to #connected_ports (#2076)
* Configuration: `environment` is read from `RAILS_ENV`, if `RACK_ENV` can't be found (#2022)
* Log binding on http:// for TCP bindings to make it clickable

* Bugfixes
* Close client http connections made to an ssl server with TLSv1.3 (#2116)
Expand Down
2 changes: 1 addition & 1 deletion lib/puma/binder.rb
Expand Up @@ -114,7 +114,7 @@ def parse(binds, logger, log_msg = 'Listening')
i.local_address.ip_unpack.join(':')
end

logger.log "* #{log_msg} on tcp://#{addr}"
logger.log "* #{log_msg} on http://#{addr}"
end
end

Expand Down
12 changes: 8 additions & 4 deletions test/test_binder.rb
Expand Up @@ -72,7 +72,7 @@ def test_home_alters_listeners_for_ssl_addresses
def test_correct_zero_port
@binder.parse ["tcp://localhost:0"], @events

m = %r!tcp://127.0.0.1:(\d+)!.match(@events.stdout.string)
m = %r!http://127.0.0.1:(\d+)!.match(@events.stdout.string)
port = m[1].to_i

refute_equal 0, port
Expand All @@ -92,9 +92,9 @@ def test_correct_zero_port_ssl
def test_logs_all_localhost_bindings
@binder.parse ["tcp://localhost:0"], @events

assert_match %r!tcp://127.0.0.1:(\d+)!, @events.stdout.string
assert_match %r!http://127.0.0.1:(\d+)!, @events.stdout.string
if Socket.ip_address_list.any? {|i| i.ipv6_loopback? }
assert_match %r!tcp://\[::1\]:(\d+)!, @events.stdout.string
assert_match %r!http://\[::1\]:(\d+)!, @events.stdout.string
end
end

Expand Down Expand Up @@ -351,13 +351,17 @@ def assert_parsing_logs_uri(order = [:unix, :tcp])
unix: "unix://test/#{name}_server.sock"
}

expected_logs = prepared_paths.dup.tap do |logs|
logs[:tcp] = logs[:tcp].gsub('tcp://', 'http://')
end

tested_paths = [prepared_paths[order[0]], prepared_paths[order[1]]]

@binder.parse tested_paths, @events
stdout = @events.stdout.string

order.each do |prot|
assert_match prepared_paths[prot], stdout
assert_match expected_logs[prot], stdout
end
ensure
@binder.close_listeners if order.include?(:unix) && UNIX_SKT_EXIST
Expand Down