-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
check for monitor server start error #1064
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
check for monitor server start error #1064
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this is good, small comments to make consistent.
server/server.go
Outdated
srv.Serve(httpListener) | ||
err := srv.Serve(httpListener) | ||
if err != nil { | ||
s.Errorf("Start %s monitor on %s error: %v", monitorProtocol, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be s.Fatalf
to match other listeners like clients?
Also maybe break out hp and make error consistent.
hp := net.JoinHostPort(opts.HTTPHost, strconv.Itoa(opts.HTTPPort))
s.Fatalf("Error starting monitoring on port: %s, %q", hp, err)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, hp
has been initialized above, thus we can reference it directly.
should the err
be formatted with %q
or %v
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually use %v.
e839990
to
2026d86
Compare
server/server.go
Outdated
@@ -1471,7 +1471,10 @@ func (s *Server) startMonitoring(secure bool) error { | |||
s.mu.Unlock() | |||
|
|||
go func() { | |||
srv.Serve(httpListener) | |||
err := srv.Serve(httpListener) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just combine?
if err := srv.Serve(httpListener); err != nil {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
server/server_test.go
Outdated
@@ -1162,6 +1162,8 @@ func TestConnectErrorReports(t *testing.T) { | |||
|
|||
remoteURLs := RoutesFromStr("nats://127.0.0.1:1234") | |||
|
|||
s.Shutdown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is deferred from above, why add here? Was test failing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, tests failed. But i have figured it out. We should only Fatalf
when not in a shutdown
stage.
2026d86
to
bb5ff7a
Compare
bb5ff7a
to
c9221fd
Compare
@derekcollison Done. PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Changes proposed in this pull request:
Serve
returned error./cc @nats-io/core