diff --git a/connection/mysql.go b/connection/mysql.go index 1233ab26..5a03936d 100644 --- a/connection/mysql.go +++ b/connection/mysql.go @@ -32,6 +32,7 @@ type DbTransaction interface { } func NewDBWrapper(dbDsn string) (*DBWrapper, error) { + log.Info("Connecting to MySQL") db, err := mkMysql("mysql", dbDsn) if err != nil { @@ -43,7 +44,10 @@ func NewDBWrapper(dbDsn string) (*DBWrapper, error) { err = dbw.Db.Ping() if err != nil { - return nil, err + log.WithFields(log.Fields{ + "context": "sql", + "error": err, + }).Error("Could not connect to SQL. Trying again") } go func() { diff --git a/connection/mysql_utils.go b/connection/mysql_utils.go index 849cb008..5bafcdea 100644 --- a/connection/mysql_utils.go +++ b/connection/mysql_utils.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "github.com/go-sql-driver/mysql" - log "github.com/sirupsen/logrus" "io/ioutil" oldlog "log" "reflect" @@ -17,8 +16,6 @@ import ( // mkMysql creates a new MySQL client. func mkMysql(dbType string, dbDsn string) (*sql.DB, error) { - log.Info("Connecting to MySQL") - sep := "?" if dbDsn == "" { diff --git a/connection/redis.go b/connection/redis.go index 2b1d22ac..0636e252 100644 --- a/connection/redis.go +++ b/connection/redis.go @@ -95,6 +95,7 @@ func (rdbw *RDBWrapper) CompareAndSetConnected(connected bool) (swapped bool) { } func NewRDBWrapper(address string) (*RDBWrapper, error) { + log.Info("Connecting to Redis") rdb := redis.NewClient(&redis.Options{ Addr: address, DialTimeout: time.Minute / 2, @@ -110,7 +111,10 @@ func NewRDBWrapper(address string) (*RDBWrapper, error) { _, err := rdbw.Rdb.Ping().Result() if err != nil { - return nil, err + log.WithFields(log.Fields{ + "context": "redis", + "error": err, + }).Error("Could not connect to Redis. Trying again") } go func() {