Skip to content

Commit

Permalink
Fix stopped server errors
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasBT committed Jan 13, 2024
1 parent ef59eb3 commit 065a2f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func main() {
srv := http.Server{Addr: conf.Addr, Handler: r}
go func() {
logger.Infof("Launching the server at %s\n", conf.Addr)
if err := srv.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) {
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
logger.Fatal(err)
}
}()
Expand Down
4 changes: 3 additions & 1 deletion cmd/servergrpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package main

import (
"errors"
"log"
"net"

Expand All @@ -12,6 +13,7 @@ import (
"github.com/matthiasBT/monitoring/internal/infra/utils"
"github.com/matthiasBT/monitoring/internal/server/adapters"
"github.com/matthiasBT/monitoring/internal/server/startup"
"google.golang.org/grpc"
)

var (
Expand Down Expand Up @@ -55,7 +57,7 @@ func main() {
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
if err := srv.Serve(lis); err != nil { // TODO: !errors.Is(err, http.ErrServerClosed) ?
if err := srv.Serve(lis); err != nil && !errors.Is(err, grpc.ErrServerStopped) {
log.Fatalf("failed to serve: %v", err)
}
}()
Expand Down

0 comments on commit 065a2f4

Please sign in to comment.