Skip to content

Commit

Permalink
Avoid logging on a clean server shutdown. (#15)
Browse files Browse the repository at this point in the history
Go's ListenAndServe methods return an error with the text "Server
close", even on a clean shutdown. We should suppress this spurious error
so it doesn't mask more meaningful ones.

Also, update to a more recent golangci-lint and exempt some lints in order
to fix the build.
  • Loading branch information
jsha authored Oct 19, 2021
1 parent 5b8a09a commit ff9b44b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ linters:
- gochecknoglobals
- gomnd
- wsl
- goerr113
- godot

issues:
exclude-use-default: true
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cache:
# `-mod=vendor` to use the vendored dependencies
install:
# Install `golangci-lint` using their installer script
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.3
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.29.0
# Install `cover` and `goveralls` without `GO111MODULE` enabled so that we
# don't download project dependencies and just put the tools in $GOPATH/bin
- GO111MODULE=off go get golang.org/x/tools/cmd/cover
Expand Down
3 changes: 2 additions & 1 deletion challenge-servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log"
"os"
"strings"
"sync"
)

Expand Down Expand Up @@ -183,7 +184,7 @@ func (s *ChallSrv) Run() {
for _, srv := range s.servers {
go func(srv challengeServer) {
err := srv.ListenAndServe()
if err != nil {
if err != nil && !strings.Contains(err.Error(), "Server closed") {
s.log.Print(err)
}
}(srv)
Expand Down

0 comments on commit ff9b44b

Please sign in to comment.