From ee6c5b7ca5d636ea9f116f74bc26ce09fad47154 Mon Sep 17 00:00:00 2001 From: lixiaoshuang <644968328@qq.com> Date: Sun, 12 Dec 2021 17:24:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9beanch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.go | 3 --- bench/http.go | 2 +- bench/main.go | 29 +++++++++++++++++++++++++++++ conf.sample.yml | 2 +- 4 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 bench/main.go diff --git a/app/main.go b/app/main.go index aaa89ed..0e344b0 100644 --- a/app/main.go +++ b/app/main.go @@ -11,7 +11,6 @@ import ( "os" "strings" - "github.com/yedf/dtm/bench" "github.com/yedf/dtm/common" "github.com/yedf/dtm/dtmcli" "github.com/yedf/dtm/dtmcli/dtmimp" @@ -66,8 +65,6 @@ func main() { // quick_start 比较独立,单独作为一个例子运行,方便新人上手 examples.QsStartSvr() examples.QsFireRequest() - case "bench": - bench.StartSvr() case "dev", "dtmsvr": default: // 下面是各类的例子 diff --git a/bench/http.go b/bench/http.go index 1d1bd4a..4308658 100644 --- a/bench/http.go +++ b/bench/http.go @@ -4,7 +4,7 @@ * license that can be found in the LICENSE file. */ -package bench +package main import ( "database/sql" diff --git a/bench/main.go b/bench/main.go new file mode 100644 index 0000000..6a2434a --- /dev/null +++ b/bench/main.go @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/yedf/dtm/common" + "github.com/yedf/dtm/dtmcli" + "github.com/yedf/dtm/dtmcli/dtmimp" + "github.com/yedf/dtm/dtmsvr" + "github.com/yedf/dtm/examples" + "os" +) + +func main() { + if len(os.Args) > 1 { + dtmimp.Logf("starting dtm....") + if os.Args[1] == "http" { + fmt.Println("start bench server") + common.MustLoadConfig() + dtmcli.SetCurrentDBType(common.DtmConfig.DB["driver"]) + common.WaitDBUp() + dtmsvr.PopulateDB(true) + examples.PopulateDB(true) + dtmsvr.StartSvr() // 启动dtmsvr的api服务 + go dtmsvr.CronExpiredTrans(-1) // 启动dtmsvr的定时过期查询 + StartSvr() + select {} + } + } +} diff --git a/conf.sample.yml b/conf.sample.yml index 4701009..b4d6217 100644 --- a/conf.sample.yml +++ b/conf.sample.yml @@ -2,7 +2,7 @@ DB: driver: 'mysql' host: 'localhost' user: 'root' - password: '' + password: '12345678' port: '3306' # driver: 'postgres'