mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 02:35:17 +01:00
Fix intermittent broken pipe
issue in log
This commit fixes #4713, by adopting the suggested fix in: https://github.com/go-sql-driver/mysql/issues/529 When creating the DB instance in orm, call `SetConnMaxLifetime()`
This commit is contained in:
parent
2f1989d211
commit
7fa8261661
@ -16,6 +16,7 @@ package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
_ "github.com/go-sql-driver/mysql" //register mysql driver
|
||||
@ -58,7 +59,12 @@ func (m *mysql) Register(alias ...string) error {
|
||||
}
|
||||
conn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s", m.usr,
|
||||
m.pwd, m.host, m.port, m.database)
|
||||
return orm.RegisterDataBase(an, "mysql", conn)
|
||||
if err := orm.RegisterDataBase(an, "mysql", conn); err != nil {
|
||||
return err
|
||||
}
|
||||
db, _ := orm.GetDB(an)
|
||||
db.SetConnMaxLifetime(5 * time.Minute)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Name returns the name of MySQL
|
||||
|
Loading…
Reference in New Issue
Block a user