Skip to content

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

Merged

Conversation

andyxning
Copy link
Contributor

Changes proposed in this pull request:

  • Add check for monitor server Serve returned error.

/cc @nats-io/core

Copy link
Member

@derekcollison derekcollison left a 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,
Copy link
Member

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)

Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually use %v.

@andyxning andyxning force-pushed the check_for_monitor_server_start_error branch 3 times, most recently from e839990 to 2026d86 Compare July 10, 2019 12:32
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)
Copy link
Member

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 {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -1162,6 +1162,8 @@ func TestConnectErrorReports(t *testing.T) {

remoteURLs := RoutesFromStr("nats://127.0.0.1:1234")

s.Shutdown()
Copy link
Member

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?

Copy link
Contributor Author

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.

@andyxning andyxning force-pushed the check_for_monitor_server_start_error branch from 2026d86 to bb5ff7a Compare July 11, 2019 03:03
@andyxning andyxning force-pushed the check_for_monitor_server_start_error branch from bb5ff7a to c9221fd Compare July 11, 2019 03:44
@andyxning
Copy link
Contributor Author

@derekcollison Done. PTAL.

Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekcollison derekcollison merged commit b868e91 into nats-io:master Jul 11, 2019
@andyxning andyxning deleted the check_for_monitor_server_start_error branch July 11, 2019 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants