Best practice http server configurations and helpers for Go 1.8's http graceful shutdown feature. Currently supports best practice configurations by:
To install this library, do:
go get github.com/ory/graceful
package main
import (
"net/http"
"log"
"github.com/ory/graceful"
)
func main() {
server := graceful.WithDefaults(&http.Server{
Addr: ":54932",
// Handler: someHandler,
})
log.Println("main: Starting the server")
if err := graceful.Graceful(server.ListenAndServe, server.Shutdown); err != nil {
log.Fatalln("main: Failed to gracefully shutdown")
}
log.Println("main: Server was shutdown gracefully")
}