fix: close db on shutdown

This commit is contained in:
Derrick Hammer 2023-08-03 08:48:49 -04:00
parent 1dd4fa22cd
commit 78ee15cf4b
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 12 additions and 0 deletions

View File

@ -63,3 +63,9 @@ func Init() {
func Get() *gorm.DB { func Get() *gorm.DB {
return db return db
} }
func Close() error {
instance, _ := db.DB()
return instance.Close()
}

View File

@ -103,4 +103,10 @@ func main() {
if err != nil { if err != nil {
logger.Get().Error("Failed starting webserver proof", zap.Error(err)) logger.Get().Error("Failed starting webserver proof", zap.Error(err))
} }
err = db.Close()
if err != nil {
logger.Get().Error("Failed to close db connection", zap.Error(err))
}
} }