From 657e96e13342a9fe968bad3fb752ad72271f2484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Tue, 17 Apr 2018 21:50:52 -0700 Subject: [PATCH] Improve graceful shutdown --- daemon/daemon.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index e8852890..cf64a1f9 100644 --- a/daemon/daemon.go +++ b/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")