forked from mirror/gorm
Returns ping error
This commit is contained in:
parent
8bb05a5a69
commit
64ed645e4d
11
gorm.go
11
gorm.go
|
@ -91,6 +91,17 @@ func Open(dialector Dialector, config *Config) (db *DB, err error) {
|
||||||
if dialector != nil {
|
if dialector != nil {
|
||||||
err = dialector.Initialize(db)
|
err = dialector.Initialize(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
if pinger, ok := db.ConnPool.(interface{ Ping() error }); ok {
|
||||||
|
err = pinger.Ping()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
config.Logger.Error(context.Background(), "failed to initialize database, got error %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue