fix: close db on shutdown
This commit is contained in:
parent
1dd4fa22cd
commit
78ee15cf4b
6
db/db.go
6
db/db.go
|
@ -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()
|
||||||
|
}
|
||||||
|
|
6
main.go
6
main.go
|
@ -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))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue