set max db connection

This commit is contained in:
nochill 2023-09-27 21:57:21 +07:00
parent 4e5bcddb4b
commit 8a677a2130

View File

@ -24,6 +24,10 @@ func main() {
log.Fatal("cannot connect to db: ", err) log.Fatal("cannot connect to db: ", err)
} }
// limit db connection
dbConn.SetConnMaxLifetime(100)
dbConn.SetMaxOpenConns(100)
store := db.NewStore(dbConn) store := db.NewStore(dbConn)
server, err := api.NewServer(config, store) server, err := api.NewServer(config, store)
if err != nil { if err != nil {