Skip to content

Commit

Permalink
cmd: handle http.ErrServerClosed properly, fix #17
Browse files Browse the repository at this point in the history
ListenAndServe _always_ returns an error, http.ErrServerClosed means it's
stopped normally, no need to panic in this case.

Signed-off-by: Roman Khimov <[email protected]>
  • Loading branch information
roman-khimov committed May 12, 2023
1 parent ca5c555 commit 68e9f0a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/neofs-oauthz/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"errors"
"fmt"
"net/http"
"strconv"
Expand Down Expand Up @@ -275,7 +276,7 @@ func (a *app) Serve(ctx context.Context) {
a.log.Info("running web server", zap.String("address", a.webServer.Addr))
err = a.webServer.ListenAndServe()
}
if err != nil {
if !errors.Is(err, http.ErrServerClosed) {
a.log.Fatal("could not start server", zap.Error(err))
}
}

0 comments on commit 68e9f0a

Please sign in to comment.