From f9dab016870a7fcbb6ee914246261d6bcd5d4fa6 Mon Sep 17 00:00:00 2001 From: huangsimin Date: Mon, 10 Dec 2018 14:58:29 +0800 Subject: [PATCH] fix timeout 15s --- logdb.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/logdb.go b/logdb.go index 08bc66d..43c0cb7 100644 --- a/logdb.go +++ b/logdb.go @@ -48,7 +48,7 @@ func (logdb *LogDB) Ping() (result bool) { log.Println(err, logdb.Hosts[logdb.hostid], " is unconnect ") hostlen := len(logdb.Hosts) for i := 0; i < hostlen; i++ { - db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?timeout=1s&charset=%s", logdb.User, logdb.Password, logdb.Hosts[i], logdb.Port, logdb.DB, logdb.Charset)) + db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?timeout=15s&charset=%s", logdb.User, logdb.Password, logdb.Hosts[i], logdb.Port, logdb.DB, logdb.Charset)) if err != nil { log.Println(err, logdb.Hosts[i], " is connect fail") continue @@ -79,7 +79,7 @@ func (logdb *LogDB) Connect() { if logdb.hostid >= len(logdb.Hosts) { logdb.hostid = 0 } - db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?timeout=1s&charset=%s", logdb.User, logdb.Password, logdb.Hosts[logdb.hostid], logdb.Port, logdb.DB, logdb.Charset)) + db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?timeout=15s&charset=%s", logdb.User, logdb.Password, logdb.Hosts[logdb.hostid], logdb.Port, logdb.DB, logdb.Charset)) if err != nil { panic(err) }