We break down how graceful HTTP server shutdown works via
(*http.Server).Shutdown(ctx), why a context without a deadline is dangerous, and which “canonical” template to use:
context.WithTimeout,
defer
cancel
(), proper logging of
context.DeadlineExceeded, and filtering
http.ErrServerClosed. We will also show graceful shutdown in
main
() via
signal.NotifyContext.