From 7a8b86ed125e4f11f8d24fbc8b97ab4e89744fa5 Mon Sep 17 00:00:00 2001 From: hoteas Date: Wed, 17 Aug 2022 16:02:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E4=BC=98=E5=8C=96,=E4=BC=98=E5=8C=96=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application.go | 9 ++------- db/hotimedb.go | 3 ++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/application.go b/application.go index f20289a..6caa23b 100644 --- a/application.go +++ b/application.go @@ -566,14 +566,9 @@ func Init(config string) *Application { codeMake["name"] = codeMake.GetString("table") } - if appIns.Config.GetInt("mode") > 0 { - appIns.MakeCodeRouter[codeMake.GetString("name")] = &code.MakeCode{Error: appIns.Error} + appIns.MakeCodeRouter[codeMake.GetString("name")] = &code.MakeCode{Error: appIns.Error} + appIns.MakeCodeRouter[codeMake.GetString("name")].Db2JSON(&appIns.Db, codeMake) - appIns.MakeCodeRouter[codeMake.GetString("name")].Db2JSON(&appIns.Db, codeMake) - } else { - appIns.MakeCodeRouter[codeMake.GetString("name")] = &code.MakeCode{Error: appIns.Error} - appIns.MakeCodeRouter[codeMake.GetString("name")].Db2JSON(nil, codeMake) - } //接入动态代码层 if appIns.Router == nil { appIns.Router = Router{} diff --git a/db/hotimedb.go b/db/hotimedb.go index a63a8a1..70c2f62 100644 --- a/db/hotimedb.go +++ b/db/hotimedb.go @@ -13,6 +13,7 @@ import ( "reflect" "sort" "strings" + "time" ) type HoTimeDB struct { @@ -314,7 +315,7 @@ func (that *HoTimeDB) InitDb(err ...*Error) *Error { e := that.SlaveDB.Ping() that.LastErr.SetError(e) } - + that.DB.SetConnMaxLifetime(time.Second) return that.LastErr }