Explorar o código

Improve graceful shutdown

Frédéric Guillot %!s(int64=8) %!d(string=hai) anos
pai
achega
657e96e133
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      daemon/daemon.go

+ 3 - 1
daemon/daemon.go

@@ -54,7 +54,9 @@ func Run(cfg *config.Config, store *storage.Storage) {
 
 	<-stop
 	logger.Info("Shutting down the server...")
-	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+	defer cancel()
+
 	server.Shutdown(ctx)
 	store.Close()
 	logger.Info("Server gracefully stopped")