mirror of
https://github.com/goharbor/harbor
synced 2025-04-13 03:15:53 +00: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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
_ "github.com/go-sql-driver/mysql" //register mysql driver
|
_ "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,
|
conn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s", m.usr,
|
||||||
m.pwd, m.host, m.port, m.database)
|
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
|
// Name returns the name of MySQL
|
||||||
|
|
Loading…
Reference in New Issue
Block a user