Skip to content
Snippets Groups Projects
Commit cd9ee1e6 authored by ale's avatar ale
Browse files

Actually start a TLS listener when necessary

parent c2c93357
No related branches found
No related tags found
No related merge requests found
......@@ -70,8 +70,8 @@ func Serve(h http.Handler, serverConfig *ServerConfig, addr string) (err error)
// down remaining clients.
ctx, cancel := context.WithTimeout(context.Background(), gracefulShutdownTimeout)
defer cancel()
if err := srv.Shutdown(ctx); err == context.Canceled {
if err := srv.Close(); err != nil {
if err = srv.Shutdown(ctx); err == context.Canceled {
if err = srv.Close(); err != nil {
log.Printf("error terminating server: %v", err)
}
}
......@@ -80,7 +80,12 @@ func Serve(h http.Handler, serverConfig *ServerConfig, addr string) (err error)
}()
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
if err := srv.ListenAndServe(); err != http.ErrServerClosed {
if tlsConfig != nil {
err = srv.ListenAndServeTLS("", "")
} else {
err = srv.ListenAndServe()
}
if err != http.ErrServerClosed {
return err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment