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 1/4] =?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' From c3a97bedd769624bd37326fbc5db4e9210990290 Mon Sep 17 00:00:00 2001 From: lixiaoshuang <644968328@qq.com> Date: Sun, 12 Dec 2021 17:25:30 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9beanch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf.sample.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.sample.yml b/conf.sample.yml index b4d6217..4701009 100644 --- a/conf.sample.yml +++ b/conf.sample.yml @@ -2,7 +2,7 @@ DB: driver: 'mysql' host: 'localhost' user: 'root' - password: '12345678' + password: '' port: '3306' # driver: 'postgres' From a59b7e1f0233f1db4d6b05f09d9efdb54a19f1da Mon Sep 17 00:00:00 2001 From: lixiaoshuang <644968328@qq.com> Date: Sun, 12 Dec 2021 17:45:43 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bench/main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bench/main.go b/bench/main.go index 6a2434a..86fab07 100644 --- a/bench/main.go +++ b/bench/main.go @@ -10,6 +10,12 @@ import ( "os" ) +var hint = `To start the bench server, you need to specify the parameters: + +Available commands: + http start bench server +` + func main() { if len(os.Args) > 1 { dtmimp.Logf("starting dtm....") @@ -24,6 +30,10 @@ func main() { go dtmsvr.CronExpiredTrans(-1) // 启动dtmsvr的定时过期查询 StartSvr() select {} + }else { + fmt.Printf(hint) } + }else { + fmt.Printf(hint) } } From d7f65dc4702f254f8cb747be8b318864dcf1f557 Mon Sep 17 00:00:00 2001 From: lixiaoshuang <644968328@qq.com> Date: Sun, 12 Dec 2021 18:32:30 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bench/main.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/bench/main.go b/bench/main.go index 86fab07..f5bfefd 100644 --- a/bench/main.go +++ b/bench/main.go @@ -17,23 +17,23 @@ Available commands: ` 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 {} - }else { - fmt.Printf(hint) - } - }else { + if len(os.Args) <= 1 { + fmt.Printf(hint) + return + } + 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 {} + } else { fmt.Printf(hint) } }