From 27284a0b3a707bc028dbb8b7722fa63a215fad89 Mon Sep 17 00:00:00 2001 From: Lukas SP Date: Mon, 24 Aug 2020 18:08:27 +0200 Subject: [PATCH] Improve storage driver termination --- cmd/pasty/main.go | 8 +++++++- internal/storage/s3_driver.go | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/pasty/main.go b/cmd/pasty/main.go index 2bb31f9..7ed39ac 100644 --- a/cmd/pasty/main.go +++ b/cmd/pasty/main.go @@ -18,7 +18,13 @@ func main() { if err != nil { panic(err) } - defer storage.Current.Terminate() + defer func() { + log.Println("Terminating the storage driver...") + err := storage.Current.Terminate() + if err != nil { + log.Fatalln(err) + } + }() // Serve the web resources log.Println("Serving the web resources...") diff --git a/internal/storage/s3_driver.go b/internal/storage/s3_driver.go index 8350afd..ba78798 100644 --- a/internal/storage/s3_driver.go +++ b/internal/storage/s3_driver.go @@ -33,7 +33,7 @@ func (driver *S3Driver) Initialize() error { return nil } -// Terminate terminates the AWS S3 storage driver +// Terminate terminates the AWS S3 storage driver (does nothing, because the AWS S3 storage driver does not need any termination) func (driver *S3Driver) Terminate() error { return nil }