From dfd196460f414edd09f62732fcd237339a17d4f3 Mon Sep 17 00:00:00 2001 From: James Elliott Date: Tue, 25 Oct 2022 16:12:42 +1100 Subject: [PATCH] refactor: close database connections on shutdown (#4255) This explicitly closes the database connection during shutdown. --- docs/content/en/configuration/miscellaneous/server.md | 2 +- internal/commands/root.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/content/en/configuration/miscellaneous/server.md b/docs/content/en/configuration/miscellaneous/server.md index 45529df05..39340d5bf 100644 --- a/docs/content/en/configuration/miscellaneous/server.md +++ b/docs/content/en/configuration/miscellaneous/server.md @@ -37,7 +37,7 @@ server: timeouts: read: 6s write: 6s - idle: 10s + idle: 30s ``` ## Options diff --git a/internal/commands/root.go b/internal/commands/root.go index 0fe843523..e9639be44 100644 --- a/internal/commands/root.go +++ b/internal/commands/root.go @@ -193,6 +193,10 @@ func runServices(config *schema.Configuration, providers middlewares.Providers, } } + if err = providers.StorageProvider.Close(); err != nil { + log.WithError(err).Errorf("Error occurred closing the database connection") + } + if err = g.Wait(); err != nil { log.WithError(err).Errorf("Error occurred waiting for shutdown") }