Skip to content

Commit

Permalink
since cleanupserver func is no longer used twice, move to g.Go func i…
Browse files Browse the repository at this point in the history
…tself
  • Loading branch information
LaurenceJJones committed Jan 18, 2024
1 parent 58f4b8f commit b862eeb
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions runner/runner.go
Expand Up @@ -47,7 +47,9 @@ func Run(router http.Handler, conf *config.Configuration) {
})
g.Go(func() error {
<-gCtx.Done()
return cleanUpServer(s)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
return s.Shutdown(ctx)
})
if err := g.Wait(); err != nil {
fmt.Println("Error while running the server", err)
Expand Down Expand Up @@ -83,12 +85,6 @@ func runTLS(s *http.Server, conf *config.Configuration) error {
return nil
}

func cleanUpServer(s *http.Server) error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
return s.Shutdown(ctx)
}

func startListening(network, addr string, keepAlive int) (net.Listener, error) {
lc := net.ListenConfig{KeepAlive: time.Duration(keepAlive) * time.Second}
conn, err := lc.Listen(context.Background(), network, addr)
Expand Down

0 comments on commit b862eeb

Please sign in to comment.