Skip to content

Commit

Permalink
fix: don't use mysql connection forever
Browse files Browse the repository at this point in the history
This fixes all the "closing bad idle connection: connection reset by peer"
  • Loading branch information
TheTipo01 committed Sep 24, 2023
1 parent 4335f14 commit 460d924
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions database/mysql/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/TheTipo01/YADMB/queue"
"github.com/bwmarrin/lit"
_ "github.com/go-sql-driver/mysql"
"time"
)

const (
Expand All @@ -33,6 +34,8 @@ func NewDatabase(dsn string) *database.Database {
// Create tables if they don't exist
database.ExecQuery(db, tblSong, tblCommands, tblBlacklist, tblLink, tblDJ)

db.SetConnMaxLifetime(time.Minute * 3)

c := common.NewCommon(db)

return &database.Database{
Expand Down

0 comments on commit 460d924

Please sign in to comment.