rpc/server: fix error reporting in Start
This error message makes no sense when shutting down the server: 2020-06-25T19:29:53.251+0300 ERROR failed to start RPC server {"error": "http: Server closed"} And ListenAndServer is documented to always return non-nil error one of which is http.ErrServerClosed. This should also fix the following test failure: ================== WARNING: DATA RACE Read at 0x00c000254243 by goroutine 49: testing.(*common).logDepth() /usr/local/go/src/testing/testing.go:665 +0xa1 testing.(*common).Logf() /usr/local/go/src/testing/testing.go:658 +0x8f testing.(*T).Logf() <autogenerated>:1 +0x75 go.uber.org/zap/zaptest.testingWriter.Write() /go/pkg/mod/go.uber.org/zap@v1.10.0/zaptest/logger.go:130 +0x11f go.uber.org/zap/zaptest.(*testingWriter).Write() <autogenerated>:1 +0xa9 go.uber.org/zap/zapcore.(*ioCore).Write() /go/pkg/mod/go.uber.org/zap@v1.10.0/zapcore/core.go:90 +0x1c3 go.uber.org/zap/zapcore.(*CheckedEntry).Write() /go/pkg/mod/go.uber.org/zap@v1.10.0/zapcore/entry.go:215 +0x1e7 go.uber.org/zap.(*Logger).Error() /go/pkg/mod/go.uber.org/zap@v1.10.0/logger.go:203 +0x95 github.com/nspcc-dev/neo-go/pkg/rpc/server.(*Server).Start() /go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server.go:179 +0x5c5 Previous write at 0x00c000254243 by goroutine 44: testing.tRunner.func1() /usr/local/go/src/testing/testing.go:900 +0x353 testing.tRunner() /usr/local/go/src/testing/testing.go:913 +0x1bb Goroutine 49 (running) created at: github.com/nspcc-dev/neo-go/pkg/rpc/server.initClearServerWithInMemoryChain() /go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_helper_test.go:69 +0x305 github.com/nspcc-dev/neo-go/pkg/rpc/server.initServerWithInMemoryChain() /go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_helper_test.go:78 +0x3c github.com/nspcc-dev/neo-go/pkg/rpc/server.testRPCProtocol() /go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_test.go:805 +0x53 github.com/nspcc-dev/neo-go/pkg/rpc/server.TestRPC.func1() /go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_test.go:793 +0x44 testing.tRunner() /usr/local/go/src/testing/testing.go:909 +0x199 Goroutine 44 (finished) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:960 +0x651 github.com/nspcc-dev/neo-go/pkg/rpc/server.TestRPC() /go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_test.go:792 +0x5d testing.tRunner() /usr/local/go/src/testing/testing.go:909 +0x199 ==================
This commit is contained in:
parent
efa8ae5be4
commit
a187336830
1 changed files with 4 additions and 4 deletions
|
@ -168,17 +168,17 @@ func (s *Server) Start(errChan chan error) {
|
|||
s.log.Info("starting rpc-server (https)", zap.String("endpoint", s.https.Addr))
|
||||
go func() {
|
||||
err := s.https.ListenAndServeTLS(cfg.CertFile, cfg.KeyFile)
|
||||
if err != nil {
|
||||
if err != http.ErrServerClosed {
|
||||
s.log.Error("failed to start TLS RPC server", zap.Error(err))
|
||||
errChan <- err
|
||||
}
|
||||
errChan <- err
|
||||
}()
|
||||
}
|
||||
err := s.ListenAndServe()
|
||||
if err != nil {
|
||||
if err != http.ErrServerClosed {
|
||||
s.log.Error("failed to start RPC server", zap.Error(err))
|
||||
errChan <- err
|
||||
}
|
||||
errChan <- err
|
||||
}
|
||||
|
||||
// Shutdown overrides the http.Server Shutdown
|
||||
|
|
Loading…
Reference in a new issue