diff --git a/cmd/stepd/main.go b/cmd/stepd/main.go index 6e1b32d..a704974 100644 --- a/cmd/stepd/main.go +++ b/cmd/stepd/main.go @@ -201,16 +201,15 @@ func main () { } // set up the HTTP server - httpServer := http.Server { + httpServer := httpServerRoutine { Addr: config.Get("http.address"), Handler: &handler, } - httpServerRoutine := httpServerRoutine(httpServer) // set up the routine manager manager := routines.Manager { Routines: []routines.Routine { - &httpServerRoutine, + &httpServer, }, } @@ -230,9 +229,10 @@ func (this *httpServerRoutine) Run (ctx context.Context) error { server := http.Server(*this) go func () { <- ctx.Done() - shutdownCtx, _ := context.WithTimeout ( + shutdownCtx, done := context.WithTimeout ( context.Background(), 16 * time.Second) + defer done() server.Shutdown(shutdownCtx) } () err := server.ListenAndServe()