You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You do not need a shutdown function to close the server. You can use the following code to achieve graceful shutdown.
// Create your own listener
l, err := net.Listen("tcp", ":7777")
if err != nil {
// handle err
}
// Start a goroutine to listen to a context and close your listener when context is done
go func() {
select {
case <-ctx.Done():
l.Close()
}
}()
if err := server.Serve(l); err != nil {
// handle err
}
Then we can shutdown it gracefully
The text was updated successfully, but these errors were encountered: