From 9d4ed4ca9fd43897abaa124143c574f28ee06cb1 Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Wed, 1 May 2019 18:39:40 -0400 Subject: [PATCH] sigint.go: close DB connection before exit Closes https://gitlab.com/commento/commento/issues/88 --- api/sigint.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/sigint.go b/api/sigint.go index 64b8e29..daaf439 100644 --- a/api/sigint.go +++ b/api/sigint.go @@ -7,7 +7,14 @@ import ( ) func sigintCleanup() int { - // TODO: close the database connection and do other cleanup jobs + if db != nil { + err := db.Close() + if err == nil { + logger.Errorf("cannot close database connection: %v", err) + return 1 + } + } + return 0 }