From 42746a528ed13c3495698c23012e91ea4ed117f7 Mon Sep 17 00:00:00 2001 From: MasterKenway Date: Tue, 3 Aug 2021 16:26:32 +0800 Subject: [PATCH 1/8] refactor: command dependence use spf13/cobra instead --- cmd/pixiu/control.go | 153 +++++++++++++++++++---------------- cmd/pixiu/pixiu.go | 37 +-------- go.mod | 10 +-- go.sum | 9 +-- pkg/common/constant/env.go | 9 +++ pkg/common/constant/key.go | 9 +++ pkg/common/constant/pixiu.go | 9 +++ pkg/logger/logger.go | 8 +- 8 files changed, 120 insertions(+), 124 deletions(-) diff --git a/cmd/pixiu/control.go b/cmd/pixiu/control.go index 61d9a7fc1..5ad39bcde 100644 --- a/cmd/pixiu/control.go +++ b/cmd/pixiu/control.go @@ -18,14 +18,18 @@ package main import ( + "os" "runtime" + "strconv" + "time" ) import ( - "github.com/urfave/cli" + "github.com/spf13/cobra" ) import ( + "github.com/apache/dubbo-go-pixiu/pkg/common/constant" "github.com/apache/dubbo-go-pixiu/pkg/config" "github.com/apache/dubbo-go-pixiu/pkg/logger" "github.com/apache/dubbo-go-pixiu/pkg/pixiu" @@ -41,99 +45,108 @@ var ( "critical": "FATAL", } - cmdStart = cli.Command{ - Name: "start", - Usage: "start dubbogo pixiu", - Flags: []cli.Flag{ - cli.StringFlag{ - Name: "config, c", - Usage: "Load configuration from `FILE`", - EnvVar: "DUBBOGO_PIXIU_CONFIG", - Value: "configs/conf.yaml", - }, - cli.StringFlag{ - Name: "api-config, a", - Usage: "Load api configuration from `FILE`", - EnvVar: "DUBBOGO_PIXIU_API_CONFIG", - Value: "configs/api_config.yaml", - }, - cli.StringFlag{ - Name: "log-config, lc", - Usage: "Load log configuration from `FILE`", - EnvVar: "LOG_FILE", - Value: "configs/log.yml", - }, - cli.StringFlag{ - Name: "log-level, l", - Usage: "dubbogo pixiu log level, trace|debug|info|warning|error|critical", - EnvVar: "LOG_LEVEL", - }, - cli.StringFlag{ - Name: "log-format, lf", - Usage: "dubbogo pixiu log format, currently useless", - }, - cli.StringFlag{ - Name: "limit-cpus, limc", - Usage: "dubbogo pixiu schedule threads count", - }, - }, - Action: func(c *cli.Context) error { - configPath := c.String("config") - apiConfigPath := c.String("api-config") - flagLogLevel := c.String("log-level") - logConfPath := c.String("log-config") + configPath string + apiConfigPath string + logConfigPath string + logLevel string + + // CURRENTLY USELESS + logFormat string + + limitCpus string - err := logger.InitLog(logConfPath) + // Currently default set to false, wait for up coming support + initFromRemote = false + + startCmd = &cobra.Command{ + Use: "dubbogo pixiu", + Short: "Dubbogo pixiu is a lightweight gateway.", + Long: "dubbo-go-pixiu is a gateway that mainly focuses on providing gateway solution to your Dubbo and RESTful \n" + + "services. It supports HTTP-to-Dubbo and HTTP-to-HTTP proxy and more protocols will be supported in the near \n" + + "future." + + "(c) " + strconv.Itoa(time.Now().Year()) + " Dubbogo", + Version: Version, + PreRun: func(cmd *cobra.Command, args []string) { + initDefaultValue() + }, + Run: func(cmd *cobra.Command, args []string) { + err := logger.InitLog(logConfigPath) if err != nil { - return err + // cause `logger.InitLog` already handle init failed, so just use logger to log + logger.Warnf("[startCmd] failed to init log config file") } - bootstrap := config.Load(configPath) - if logLevel, ok := flagToLogLevel[flagLogLevel]; ok { - logger.SetLoggerLevel(logLevel) + if level, ok := flagToLogLevel[logLevel]; ok { + logger.SetLoggerLevel(level) + } else { + logger.Warnf("[startCmd] logLevel is invalid, set log level to default: %s", constant.DefaultLogLevel) + logger.SetLoggerLevel(flagToLogLevel[constant.DefaultLogLevel]) } - initFromRemote := false + bootstrap := config.Load(configPath) + // get api config from meta data center if bootstrap.GetAPIMetaConfig() != nil { if _, err := config.LoadAPIConfig(bootstrap.GetAPIMetaConfig()); err != nil { - logger.Warnf("load api config from etcd error:%+v", err) - } else { - initFromRemote = true + logger.Warnf("[startCmd] failed to get api meta config, %s", err.Error()) } } + // get api config from local file if !initFromRemote { if _, err := config.LoadAPIConfigFromFile(apiConfigPath); err != nil { - logger.Errorf("load api config error:%+v", err) - return err + logger.Errorf("[startCmd] failed to load api config from file, %s", err.Error()) } } - limitCpus := c.Int("limit-cpus") - if limitCpus <= 0 { + limitCpuNumber, err := strconv.ParseInt(limitCpus, 10, 64) + if err != nil { + logger.Errorf("[startCmd] failed to get limit cpu number, %s", err.Error()) + } + if limitCpuNumber <= 0 { runtime.GOMAXPROCS(runtime.NumCPU()) } else { - runtime.GOMAXPROCS(limitCpus) + runtime.GOMAXPROCS(int(limitCpuNumber)) } pixiu.Start(bootstrap) - return nil }, } +) - cmdStop = cli.Command{ - Name: "stop", - Usage: "stop dubbogo pixiu", - Action: func(c *cli.Context) error { - return nil - }, +// init Init startCmd +func init() { + startCmd.PersistentFlags().StringVarP(&configPath, constant.ConfigPathKey, "c", os.Getenv(constant.EnvDubbogoPixiuConfig), "Load configuration from `FILE`") + startCmd.PersistentFlags().StringVarP(&apiConfigPath, constant.ApiConfigPathKey, "a", os.Getenv(constant.EnvDubbogoPixiuApiConfig), "Load api configuration from `FILE`") + startCmd.PersistentFlags().StringVarP(&logConfigPath, constant.LogConfigPathKey, "g", os.Getenv(constant.EnvDubbogoPixiuLogConfig), "Load log configuration from `FILE`") + startCmd.PersistentFlags().StringVarP(&logLevel, constant.LogLevelKey, "l", os.Getenv(constant.EnvDubbogoPixiuLogLevel), "dubbogo pixiu log level, trace|debug|info|warning|error|critical") + startCmd.PersistentFlags().StringVarP(&limitCpus, constant.LimitCpusKey, "m", os.Getenv(constant.EnvDubbogoPixiuLimitCpus), "dubbogo pixiu schedule threads count") + startCmd.PersistentFlags().StringVarP(&logFormat, constant.LogFormatKey, "f", os.Getenv(constant.EnvDubbogoPixiuLogFormat), "dubbogo pixiu log format, currently useless") + +} + +// initDefaultValue If not set both in args and env, set default values +func initDefaultValue() { + if configPath == "" { + configPath = constant.DefaultConfigPath } - cmdReload = cli.Command{ - Name: "reload", - Usage: "reconfiguration", - Action: func(c *cli.Context) error { - return nil - }, + if apiConfigPath == "" { + apiConfigPath = constant.DefaultApiConfigPath } -) + + if logConfigPath != "" { + logConfigPath = constant.DefaultLogConfigPath + } + + if logLevel == "" { + logLevel = constant.DefaultLogLevel + } + + if limitCpus == "" { + limitCpus = constant.DefaultLimitCpus + } + + if logFormat != "" { + logFormat = constant.DefaultLogFormat + } +} diff --git a/cmd/pixiu/pixiu.go b/cmd/pixiu/pixiu.go index ceebd78c6..fe6df95cb 100644 --- a/cmd/pixiu/pixiu.go +++ b/cmd/pixiu/pixiu.go @@ -19,16 +19,11 @@ package main import ( _ "net/http/pprof" - "os" - "strconv" - "time" ) import ( _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" _ "github.com/apache/dubbo-go/metadata/service/inmemory" - - "github.com/urfave/cli" ) // Version pixiu version @@ -36,36 +31,8 @@ var Version = "0.3.0" // main pixiu run method func main() { - app := newPXApp(&cmdStart) + app := startCmd // ignore error so we don't exit non-zero and break gfmrun README example tests - _ = app.Run(os.Args) -} - -func newPXApp(startCmd *cli.Command) *cli.App { - app := cli.NewApp() - app.Name = "dubbogo pixiu" - app.Version = Version - app.Compiled = time.Now() - app.Copyright = "(c) " + strconv.Itoa(time.Now().Year()) + " Dubbogo" - app.Usage = "Dubbogo pixiu is a lightweight gateway." - app.Flags = cmdStart.Flags - - // commands - app.Commands = []cli.Command{ - cmdStart, - cmdStop, - cmdReload, - } - - // action - app.Action = func(c *cli.Context) error { - if c.NumFlags() == 0 { - return cli.ShowAppHelp(c) - } - - return startCmd.Action.(func(c *cli.Context) error)(c) - } - - return app + _ = app.Execute() } diff --git a/go.mod b/go.mod index 50ee41b01..6914bff55 100644 --- a/go.mod +++ b/go.mod @@ -4,26 +4,24 @@ go 1.14 require ( github.com/alibaba/sentinel-golang v1.0.2 - github.com/apache/dubbo-go v1.5.7-rc2 + github.com/apache/dubbo-go v1.5.7-rc1 github.com/apache/dubbo-go-hessian2 v1.9.2 github.com/dubbogo/dubbo-go-pixiu-filter v0.1.4-0.20210613012702-8488bf80772c github.com/dubbogo/go-zookeeper v1.0.3 - github.com/dubbogo/gost v1.11.14 + github.com/dubbogo/gost v1.11.8 github.com/emirpasic/gods v1.12.0 github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9 github.com/golang/protobuf v1.5.2 // indirect - github.com/google/uuid v1.2.0 // indirect github.com/hashicorp/consul/api v1.5.0 github.com/pkg/errors v0.9.1 github.com/prometheus/common v0.29.0 // indirect github.com/shirou/gopsutil v3.21.3+incompatible // indirect github.com/spf13/cast v1.3.1 + github.com/spf13/cobra v0.0.5 github.com/stretchr/testify v1.7.0 github.com/tklauser/go-sysconf v0.3.5 // indirect - github.com/urfave/cli v1.22.4 - go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 // indirect - go.etcd.io/etcd/api/v3 v3.5.0-alpha.0 + go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 go.opentelemetry.io/otel v1.0.0-RC1 go.opentelemetry.io/otel/exporters/prometheus v0.21.0 go.opentelemetry.io/otel/metric v0.21.0 diff --git a/go.sum b/go.sum index 1fed2bc23..a461469f3 100644 --- a/go.sum +++ b/go.sum @@ -186,9 +186,7 @@ github.com/coreos/go-systemd/v22 v22.1.0 h1:kq/SbG2BCKLkDKkjQf5OWwKWUKj1lgs3lFI4 github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -521,6 +519,7 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= @@ -764,9 +763,7 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/zerolog v1.4.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= -github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= @@ -787,7 +784,6 @@ github.com/shirou/gopsutil v3.21.3+incompatible h1:uenXGGa8ESCQq+dbgtl916dmg6PSA github.com/shirou/gopsutil v3.21.3+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= -github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -816,6 +812,7 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= @@ -870,8 +867,6 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA= -github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/vmware/govmomi v0.18.0 h1:f7QxSmP7meCtoAmiKZogvVbLInT+CZx6Px6K5rYsJZo= github.com/vmware/govmomi v0.18.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc= diff --git a/pkg/common/constant/env.go b/pkg/common/constant/env.go index 5d008b6ae..d51e88903 100644 --- a/pkg/common/constant/env.go +++ b/pkg/common/constant/env.go @@ -22,3 +22,12 @@ const ( EnvResponseStrategy = "dgp-response-strategy" EnvMock = "dgp-mock" ) + +const ( + EnvDubbogoPixiuConfig = "DUBBOGO_PIXIU_CONFIG" + EnvDubbogoPixiuApiConfig = "DUBBOGO_PIXIU_API_CONFIG" + EnvDubbogoPixiuLogConfig = "DUBBOGO_PIXIU_LOG_CONFIG" + EnvDubbogoPixiuLogLevel = "DUBBOGO_PIXIU_LOG_LEVEL" + EnvDubbogoPixiuLogFormat = "DUBBOGO_PIXIU_LOG_FORMAT" + EnvDubbogoPixiuLimitCpus = "DUBBOGO_PIXIU_LIMIT_CPUS" +) diff --git a/pkg/common/constant/key.go b/pkg/common/constant/key.go index 95ae76c2a..672d8d4d1 100644 --- a/pkg/common/constant/key.go +++ b/pkg/common/constant/key.go @@ -35,3 +35,12 @@ const ( const ( LocalMemoryApiDiscoveryService = "api.ds.local_memory" ) + +const ( + ConfigPathKey = "config" + ApiConfigPathKey = "api-config" + LogConfigPathKey = "log-config" + LogLevelKey = "log-level" + LimitCpusKey = "limit-cpus" + LogFormatKey = "log-format" +) diff --git a/pkg/common/constant/pixiu.go b/pkg/common/constant/pixiu.go index dac58845e..b830ca0d2 100644 --- a/pkg/common/constant/pixiu.go +++ b/pkg/common/constant/pixiu.go @@ -57,3 +57,12 @@ const ( //YML .yml YML = ".yml" ) + +const ( + DefaultConfigPath = "configs/conf.yaml" + DefaultApiConfigPath = "configs/api_config.yaml" + DefaultLogConfigPath = "configs/log.yml" + DefaultLogLevel = "info" + DefaultLimitCpus = "0" + DefaultLogFormat = "" +) diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 459436718..a8ef1d6b1 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -59,13 +59,9 @@ type Logger interface { } func init() { - // TODO: Reserve for testing, using a better way? + // only use in test case, so just load default config if logger == nil { - logConfFile := "./conf/log.yml" - err := InitLog(logConfFile) - if err != nil { - logger.Infof("[InitLog] warn: %v", err) - } + InitLogger(nil) } } From 15708c4bee22feda012387dd990a2c4a7e3be279 Mon Sep 17 00:00:00 2001 From: MasterKenway Date: Tue, 3 Aug 2021 16:47:29 +0800 Subject: [PATCH 2/8] fix: etcd event type error fix: license check add ignore folder `vendor` --- .travis.yml | 2 +- go.mod | 10 ++++++---- go.sum | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 35c51be26..d57779f7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ script: - go fmt ./... && [[ -z `git status -s` ]] - sh before_validate_license.sh - chmod u+x /tmp/tools/license/license-header-checker - - /tmp/tools/license/license-header-checker -v -a -r -i vendor -i .github/actions /tmp/tools/license/license.txt . go && [[ -z `git status -s` ]] + - /tmp/tools/license/license-header-checker -v -a -r -i vendor,.github/actions /tmp/tools/license/license.txt . go && [[ -z `git status -s` ]] # unit-test - echo 'start unit-test' - chmod u+x before_ut.sh && ./before_ut.sh diff --git a/go.mod b/go.mod index 6914bff55..44d125f14 100644 --- a/go.mod +++ b/go.mod @@ -4,24 +4,26 @@ go 1.14 require ( github.com/alibaba/sentinel-golang v1.0.2 - github.com/apache/dubbo-go v1.5.7-rc1 + github.com/apache/dubbo-go v1.5.7-rc2 github.com/apache/dubbo-go-hessian2 v1.9.2 github.com/dubbogo/dubbo-go-pixiu-filter v0.1.4-0.20210613012702-8488bf80772c github.com/dubbogo/go-zookeeper v1.0.3 - github.com/dubbogo/gost v1.11.8 + github.com/dubbogo/gost v1.11.14 github.com/emirpasic/gods v1.12.0 github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9 github.com/golang/protobuf v1.5.2 // indirect + github.com/google/uuid v1.2.0 // indirect github.com/hashicorp/consul/api v1.5.0 github.com/pkg/errors v0.9.1 github.com/prometheus/common v0.29.0 // indirect github.com/shirou/gopsutil v3.21.3+incompatible // indirect github.com/spf13/cast v1.3.1 - github.com/spf13/cobra v0.0.5 + github.com/spf13/cobra v1.1.1 github.com/stretchr/testify v1.7.0 github.com/tklauser/go-sysconf v0.3.5 // indirect - go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 + go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 // indirect + go.etcd.io/etcd/api/v3 v3.5.0-alpha.0 go.opentelemetry.io/otel v1.0.0-RC1 go.opentelemetry.io/otel/exporters/prometheus v0.21.0 go.opentelemetry.io/otel/metric v0.21.0 diff --git a/go.sum b/go.sum index a461469f3..2ea270d37 100644 --- a/go.sum +++ b/go.sum @@ -814,6 +814,7 @@ github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= @@ -878,6 +879,7 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zouyx/agollo/v3 v3.4.5 h1:7YCxzY9ZYaH9TuVUBvmI6Tk0mwMggikah+cfbYogcHQ= github.com/zouyx/agollo/v3 v3.4.5/go.mod h1:LJr3kDmm23QSW+F1Ol4TMHDa7HvJvscMdVxJ2IpUTVc= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= @@ -890,6 +892,8 @@ go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 h1:jWtjCJX1qxhHISBMLRztWwR+EX go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698/go.mod h1:YoUyTScD3Vcv2RBm3eGVOq7i1ULiz3OuXoQFWOirmAM= go.etcd.io/etcd/api/v3 v3.5.0-alpha.0 h1:+e5nrluATIy3GP53znpkHMFzPTHGYyzvJGFCbuI6ZLc= go.etcd.io/etcd/api/v3 v3.5.0-alpha.0/go.mod h1:mPcW6aZJukV6Aa81LSKpBjQXTWlXB5r74ymPoSWa3Sw= +go.etcd.io/etcd/api/v3 v3.5.0 h1:GsV3S+OfZEOCNXdtNkBSR7kgLobAa/SO6tCxRa0GAYw= +go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/client/v2 v2.305.0-alpha.0/go.mod h1:kdV+xzCJ3luEBSIeQyB/OEKkWKd8Zkux4sbDeANrosU= go.etcd.io/etcd/client/v3 v3.5.0-alpha.0 h1:dr1EOILak2pu4Nf5XbRIOCNIBjcz6UmkQd7hHRXwxaM= go.etcd.io/etcd/client/v3 v3.5.0-alpha.0/go.mod h1:wKt7jgDgf/OfKiYmCq5WFGxOFAkVMLxiiXgLDFhECr8= @@ -981,6 +985,7 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -990,6 +995,7 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1032,6 +1038,7 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1052,6 +1059,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1113,7 +1122,9 @@ golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1126,6 +1137,7 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1186,6 +1198,7 @@ golang.org/x/tools v0.0.0-20200928182047-19e03678916f/go.mod h1:z6u4i615ZeAfBE4X golang.org/x/tools v0.0.0-20201014170642-d1624618ad65/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1234,6 +1247,8 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987 h1:PDIOdWxZ8eRizhKa1AAvY53xsvLB1cWorMjslvY3VA8= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/grpc v1.26.0 h1:2dTRdpdFEEhJYQD8EMLB61nnrzSCTbG38PhqdhvOltg= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= From 24034fe855835d74e99f8a4f3c1426846fde9975 Mon Sep 17 00:00:00 2001 From: MasterKenway Date: Tue, 3 Aug 2021 21:19:06 +0800 Subject: [PATCH 3/8] refactor: move init operation out of start gateway command to fit sidecar mode in the future --- .gitignore | 1 + Makefile | 4 +- cmd/pixiu/control.go | 152 ------------------------------------------- cmd/pixiu/gateway.go | 75 +++++++++++++++++++++ cmd/pixiu/pixiu.go | 136 +++++++++++++++++++++++++++++++++++++- cmd/pixiu/sidecar.go | 16 +++++ start.sh | 2 +- 7 files changed, 228 insertions(+), 158 deletions(-) delete mode 100644 cmd/pixiu/control.go create mode 100644 cmd/pixiu/gateway.go create mode 100644 cmd/pixiu/sidecar.go diff --git a/.gitignore b/.gitignore index 60a944432..97077b963 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ pkg/registry/zookeeper-4unittest/contrib/fatjar coverage.txt +/vendor/ diff --git a/Makefile b/Makefile index a7e1bec26..e8b7d6227 100644 --- a/Makefile +++ b/Makefile @@ -44,11 +44,11 @@ ifeq (windows,$(os)) targetName = dubbo-go-pixiu.exe endif exe := $(mainPath)$(targetName) -gobuild: +build: cd $(mainPath) && go build -o $(currentPath)/$(targetName) *.go run: build - ./dubbo-go-pixiu start -a $(api-config-path) -c $(config-path) + ./dubbo-go-pixiu start-gateway -a $(api-config-path) -c $(config-path) license-check-util: go install github.com/lsm-dev/license-header-checker/cmd/license-header-checker@latest diff --git a/cmd/pixiu/control.go b/cmd/pixiu/control.go deleted file mode 100644 index 5ad39bcde..000000000 --- a/cmd/pixiu/control.go +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package main - -import ( - "os" - "runtime" - "strconv" - "time" -) - -import ( - "github.com/spf13/cobra" -) - -import ( - "github.com/apache/dubbo-go-pixiu/pkg/common/constant" - "github.com/apache/dubbo-go-pixiu/pkg/config" - "github.com/apache/dubbo-go-pixiu/pkg/logger" - "github.com/apache/dubbo-go-pixiu/pkg/pixiu" -) - -var ( - flagToLogLevel = map[string]string{ - "trace": "TRACE", - "debug": "DEBUG", - "info": "INFO", - "warning": "WARN", - "error": "ERROR", - "critical": "FATAL", - } - - configPath string - apiConfigPath string - logConfigPath string - logLevel string - - // CURRENTLY USELESS - logFormat string - - limitCpus string - - // Currently default set to false, wait for up coming support - initFromRemote = false - - startCmd = &cobra.Command{ - Use: "dubbogo pixiu", - Short: "Dubbogo pixiu is a lightweight gateway.", - Long: "dubbo-go-pixiu is a gateway that mainly focuses on providing gateway solution to your Dubbo and RESTful \n" + - "services. It supports HTTP-to-Dubbo and HTTP-to-HTTP proxy and more protocols will be supported in the near \n" + - "future." + - "(c) " + strconv.Itoa(time.Now().Year()) + " Dubbogo", - Version: Version, - PreRun: func(cmd *cobra.Command, args []string) { - initDefaultValue() - }, - Run: func(cmd *cobra.Command, args []string) { - err := logger.InitLog(logConfigPath) - if err != nil { - // cause `logger.InitLog` already handle init failed, so just use logger to log - logger.Warnf("[startCmd] failed to init log config file") - } - - if level, ok := flagToLogLevel[logLevel]; ok { - logger.SetLoggerLevel(level) - } else { - logger.Warnf("[startCmd] logLevel is invalid, set log level to default: %s", constant.DefaultLogLevel) - logger.SetLoggerLevel(flagToLogLevel[constant.DefaultLogLevel]) - } - - bootstrap := config.Load(configPath) - // get api config from meta data center - if bootstrap.GetAPIMetaConfig() != nil { - if _, err := config.LoadAPIConfig(bootstrap.GetAPIMetaConfig()); err != nil { - logger.Warnf("[startCmd] failed to get api meta config, %s", err.Error()) - } - } - - // get api config from local file - if !initFromRemote { - if _, err := config.LoadAPIConfigFromFile(apiConfigPath); err != nil { - logger.Errorf("[startCmd] failed to load api config from file, %s", err.Error()) - } - } - - limitCpuNumber, err := strconv.ParseInt(limitCpus, 10, 64) - if err != nil { - logger.Errorf("[startCmd] failed to get limit cpu number, %s", err.Error()) - } - if limitCpuNumber <= 0 { - runtime.GOMAXPROCS(runtime.NumCPU()) - } else { - runtime.GOMAXPROCS(int(limitCpuNumber)) - } - - pixiu.Start(bootstrap) - }, - } -) - -// init Init startCmd -func init() { - startCmd.PersistentFlags().StringVarP(&configPath, constant.ConfigPathKey, "c", os.Getenv(constant.EnvDubbogoPixiuConfig), "Load configuration from `FILE`") - startCmd.PersistentFlags().StringVarP(&apiConfigPath, constant.ApiConfigPathKey, "a", os.Getenv(constant.EnvDubbogoPixiuApiConfig), "Load api configuration from `FILE`") - startCmd.PersistentFlags().StringVarP(&logConfigPath, constant.LogConfigPathKey, "g", os.Getenv(constant.EnvDubbogoPixiuLogConfig), "Load log configuration from `FILE`") - startCmd.PersistentFlags().StringVarP(&logLevel, constant.LogLevelKey, "l", os.Getenv(constant.EnvDubbogoPixiuLogLevel), "dubbogo pixiu log level, trace|debug|info|warning|error|critical") - startCmd.PersistentFlags().StringVarP(&limitCpus, constant.LimitCpusKey, "m", os.Getenv(constant.EnvDubbogoPixiuLimitCpus), "dubbogo pixiu schedule threads count") - startCmd.PersistentFlags().StringVarP(&logFormat, constant.LogFormatKey, "f", os.Getenv(constant.EnvDubbogoPixiuLogFormat), "dubbogo pixiu log format, currently useless") - -} - -// initDefaultValue If not set both in args and env, set default values -func initDefaultValue() { - if configPath == "" { - configPath = constant.DefaultConfigPath - } - - if apiConfigPath == "" { - apiConfigPath = constant.DefaultApiConfigPath - } - - if logConfigPath != "" { - logConfigPath = constant.DefaultLogConfigPath - } - - if logLevel == "" { - logLevel = constant.DefaultLogLevel - } - - if limitCpus == "" { - limitCpus = constant.DefaultLimitCpus - } - - if logFormat != "" { - logFormat = constant.DefaultLogFormat - } -} diff --git a/cmd/pixiu/gateway.go b/cmd/pixiu/gateway.go new file mode 100644 index 000000000..8588516e4 --- /dev/null +++ b/cmd/pixiu/gateway.go @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "os" +) + +import ( + "github.com/spf13/cobra" +) + +import ( + "github.com/apache/dubbo-go-pixiu/pkg/common/constant" + "github.com/apache/dubbo-go-pixiu/pkg/logger" + "github.com/apache/dubbo-go-pixiu/pkg/pixiu" +) + +var ( + startGatewayCmd = &cobra.Command{ + Use: "start-gateway", + Short: "Run dubbo go pixiu in gateway mode", + Version: Version, + PreRun: func(cmd *cobra.Command, args []string) { + initDefaultValue() + }, + Run: func(cmd *cobra.Command, args []string) { + err := initLog() + if err != nil { + logger.Warnf("[startGatewayCmd] failed to init logger, %s", err.Error()) + } + + bootstrap, meta, err := initApiConfig() + if err != nil { + if meta { + logger.Warnf("[startGatewayCmd] failed to get api meta config, %s", err.Error()) + } else { + logger.Errorf("[startGatewayCmd] failed to get api meta config, %s", err.Error()) + } + } + + err = initLimitCpus() + if err != nil { + logger.Errorf("[startCmd] failed to get limit cpu number, %s", err.Error()) + } + + pixiu.Start(bootstrap) + }, + } +) + +// init Init startCmd +func init() { + startGatewayCmd.PersistentFlags().StringVarP(&configPath, constant.ConfigPathKey, "c", os.Getenv(constant.EnvDubbogoPixiuConfig), "Load configuration from `FILE`") + startGatewayCmd.PersistentFlags().StringVarP(&apiConfigPath, constant.ApiConfigPathKey, "a", os.Getenv(constant.EnvDubbogoPixiuApiConfig), "Load api configuration from `FILE`") + startGatewayCmd.PersistentFlags().StringVarP(&logConfigPath, constant.LogConfigPathKey, "g", os.Getenv(constant.EnvDubbogoPixiuLogConfig), "Load log configuration from `FILE`") + startGatewayCmd.PersistentFlags().StringVarP(&logLevel, constant.LogLevelKey, "l", os.Getenv(constant.EnvDubbogoPixiuLogLevel), "dubbogo pixiu log level, trace|debug|info|warning|error|critical") + startGatewayCmd.PersistentFlags().StringVarP(&limitCpus, constant.LimitCpusKey, "m", os.Getenv(constant.EnvDubbogoPixiuLimitCpus), "dubbogo pixiu schedule threads count") + startGatewayCmd.PersistentFlags().StringVarP(&logFormat, constant.LogFormatKey, "f", os.Getenv(constant.EnvDubbogoPixiuLogFormat), "dubbogo pixiu log format, currently useless") +} diff --git a/cmd/pixiu/pixiu.go b/cmd/pixiu/pixiu.go index fe6df95cb..2d05fc94d 100644 --- a/cmd/pixiu/pixiu.go +++ b/cmd/pixiu/pixiu.go @@ -18,21 +18,151 @@ package main import ( + "errors" + "fmt" _ "net/http/pprof" + "runtime" + "strconv" + "time" +) + +import ( + "github.com/apache/dubbo-go-pixiu/pkg/common/constant" + "github.com/apache/dubbo-go-pixiu/pkg/config" + "github.com/apache/dubbo-go-pixiu/pkg/logger" + "github.com/apache/dubbo-go-pixiu/pkg/model" ) import ( _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" _ "github.com/apache/dubbo-go/metadata/service/inmemory" + "github.com/spf13/cobra" ) -// Version pixiu version -var Version = "0.3.0" +var ( + // Version pixiu version + Version = "0.3.0" + + flagToLogLevel = map[string]string{ + "trace": "TRACE", + "debug": "DEBUG", + "info": "INFO", + "warning": "WARN", + "error": "ERROR", + "critical": "FATAL", + } + + configPath string + apiConfigPath string + logConfigPath string + logLevel string + + // CURRENTLY USELESS + logFormat string + + limitCpus string + + // Currently default set to false, wait for up coming support + initFromRemote = false +) // main pixiu run method func main() { - app := startCmd + app := getRootCmd() // ignore error so we don't exit non-zero and break gfmrun README example tests _ = app.Execute() } + +func getRootCmd() *cobra.Command { + rootCmd := &cobra.Command{ + Use: "dubbogo pixiu", + Short: "Dubbogo pixiu is a lightweight gateway.", + Long: "dubbo-go-pixiu is a gateway that mainly focuses on providing gateway solution to your Dubbo and RESTful \n" + + "services. It supports HTTP-to-Dubbo and HTTP-to-HTTP proxy and more protocols will be supported in the near \n" + + "future." + + "(c) " + strconv.Itoa(time.Now().Year()) + " Dubbogo", + Version: Version, + } + + rootCmd.AddCommand(startGatewayCmd) + rootCmd.AddCommand(startSideCarCmd) + + return rootCmd +} + +// initDefaultValue If not set both in args and env, set default values +func initDefaultValue() { + if configPath == "" { + configPath = constant.DefaultConfigPath + } + + if apiConfigPath == "" { + apiConfigPath = constant.DefaultApiConfigPath + } + + if logConfigPath != "" { + logConfigPath = constant.DefaultLogConfigPath + } + + if logLevel == "" { + logLevel = constant.DefaultLogLevel + } + + if limitCpus == "" { + limitCpus = constant.DefaultLimitCpus + } + + if logFormat != "" { + logFormat = constant.DefaultLogFormat + } +} + +// initLog +func initLog() error { + err := logger.InitLog(logConfigPath) + if err != nil { + // cause `logger.InitLog` already handle init failed, so just use logger to log + return err + } + + if level, ok := flagToLogLevel[logLevel]; ok { + logger.SetLoggerLevel(level) + } else { + logger.SetLoggerLevel(flagToLogLevel[constant.DefaultLogLevel]) + return errors.New(fmt.Sprintf("logLevel is invalid, set log level to default: %s", constant.DefaultLogLevel)) + } + return nil +} + +// initApiConfig return value of the bool is for the judgment of whether is a api meta data error, a kind of silly (?) +func initApiConfig() (*model.Bootstrap, bool, error) { + bootstrap := config.Load(configPath) + // get api config from meta data center + if bootstrap.GetAPIMetaConfig() != nil { + if _, err := config.LoadAPIConfig(bootstrap.GetAPIMetaConfig()); err != nil { + return nil, true, err + } + } + + // get api config from local file + if !initFromRemote { + if _, err := config.LoadAPIConfigFromFile(apiConfigPath); err != nil { + return nil, false, err + } + } + return bootstrap, false, nil +} + +func initLimitCpus() error { + limitCpuNumber, err := strconv.ParseInt(limitCpus, 10, 64) + if err != nil { + return err + } + if limitCpuNumber <= 0 { + runtime.GOMAXPROCS(runtime.NumCPU()) + } else { + runtime.GOMAXPROCS(int(limitCpuNumber)) + } + return nil +} diff --git a/cmd/pixiu/sidecar.go b/cmd/pixiu/sidecar.go new file mode 100644 index 000000000..2a4e798fc --- /dev/null +++ b/cmd/pixiu/sidecar.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" + "github.com/spf13/cobra" +) + +var ( + startSideCarCmd = &cobra.Command{ + Use: "start-sidecar", + Short: "Run dubbo go pixiu in sidecar mode (implement in the future)", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("Meet you in the Future!") + }, + } +) diff --git a/start.sh b/start.sh index af254e078..561625328 100755 --- a/start.sh +++ b/start.sh @@ -26,4 +26,4 @@ PROJECT_HOME=${PROJECT_HOME}"/" export CONF_CONSUMER_FILE_PATH=${PROJECT_HOME}"conf/client.yml" export APP_LOG_CONF_FILE=${PROJECT_HOME}"conf/log.yml" -./dubbo-go-pixiu ${args} \ No newline at end of file +./dubbo-go-pixiu start-gateway ${args} \ No newline at end of file From d34f24156d8695c4a5f48ce1785cbfb3bf37c575 Mon Sep 17 00:00:00 2001 From: MasterKenway Date: Tue, 3 Aug 2021 21:22:19 +0800 Subject: [PATCH 4/8] fix: add license header --- cmd/pixiu/sidecar.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cmd/pixiu/sidecar.go b/cmd/pixiu/sidecar.go index 2a4e798fc..be12b2a6e 100644 --- a/cmd/pixiu/sidecar.go +++ b/cmd/pixiu/sidecar.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main import ( From 768a6177118bb60d296c4473d33db7fa024095b0 Mon Sep 17 00:00:00 2001 From: MasterKenway Date: Tue, 3 Aug 2021 23:48:51 +0800 Subject: [PATCH 5/8] fix: integrate test --- igt/Makefile | 9 +++++---- samples/dubbogo/simple/start.sh | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/igt/Makefile b/igt/Makefile index 9cefb11c4..d1751708a 100644 --- a/igt/Makefile +++ b/igt/Makefile @@ -32,7 +32,7 @@ export GOPROXY ?= https://goproxy.io,direct export GOSUMDB ?= sum.golang.org export GOARCH ?= amd64 -export DOCKER_HOST_IP = $(shell ifconfig en0 | grep inet | grep -v inet6 | awk '{print $$2}') +export DOCKER_HOST_IP = $(shell hostname) OS := $(shell uname) ifeq ($(OS), Linux) @@ -59,7 +59,7 @@ else LDFLAGS := "-s -w" endif -OUT_DIR := $(BASE_DIR)/$(GOOS)_$(GOARCH)/$(rtfg8u7) +OUT_DIR := $(BASE_DIR)/$(GOOS)_$(GOARCH) LOG_FILE := $(OUT_DIR)/$(PROJECT_NAME).log API_CONFIG_PATH := $(OUT_DIR)/pixiuconf/api_config.yaml CONFIG_PATH := $(OUT_DIR)/pixiuconf/conf.yaml @@ -82,6 +82,7 @@ build: $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME) config .PHONY: $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME) $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME): $(info > Buiding application binary: $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME)) + @echo $(OUT_DIR)/server/$(PROJECT_NAME)$(EXT_NAME) @CGO_ENABLED=$(CGO) GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(GCFLAGS) -ldflags=$(LDFLAGS) -i -o $(OUT_DIR)/server/$(PROJECT_NAME)$(EXT_NAME) $(SOURCES) @@ -132,8 +133,8 @@ run: buildPixiu ## buildPixiu: start pixiu .PHONY: buildPixiu buildPixiu: - @CGO_ENABLED=$(CGO) GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(GCFLAGS) -ldflags=$(LDFLAGS) -i -o $(OUT_DIR)/pixiu$(EXT_NAME) $(pixiuSources) - @-$(OUT_DIR)/pixiu$(EXT_NAME) -a $(API_CONFIG_PATH) -c $(CONFIG_PATH) & echo $$! > $(PIXIU_PID) + @CGO_ENABLED=$(CGO) GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(GCFLAGS) -ldflags=$(LDFLAGS) -i -o $(OUT_DIR)/dubbo-go-pixiu$(EXT_NAME) $(pixiuSources) + @-$(OUT_DIR)/dubbo-go-pixiu$(EXT_NAME) start-gateway -a $(API_CONFIG_PATH) -c $(CONFIG_PATH) & echo $$! > $(PIXIU_PID) @cat $(PIXIU_PID) | sed "/^/s/^/ \> PIXIU_PID: /" ## stop: Stop running the application (for server) .PHONY: stop diff --git a/samples/dubbogo/simple/start.sh b/samples/dubbogo/simple/start.sh index b775c24be..59adc999c 100755 --- a/samples/dubbogo/simple/start.sh +++ b/samples/dubbogo/simple/start.sh @@ -22,4 +22,4 @@ DIR=$(cd $(dirname $0) && pwd ) echo $DIR -./pixiu -c ${DIR}/$1/pixiu/conf.yaml -a ${DIR}/$1/pixiu/api_config.yaml \ No newline at end of file +./dubbo-go-pixiu start-gateway -c ${DIR}/$1/pixiu/conf.yaml -a ${DIR}/$1/pixiu/api_config.yaml \ No newline at end of file From 19afc506e47d4d2012d2633982a46b4bc8dac0bb Mon Sep 17 00:00:00 2001 From: MasterKenway Date: Wed, 4 Aug 2021 10:50:30 +0800 Subject: [PATCH 6/8] style: command change from `./dubbo-go-pixiu start-gateway` to `./dubbo-go-pixiu gateway start` --- Makefile | 2 +- cmd/pixiu/gateway.go | 11 +++++++++-- cmd/pixiu/pixiu.go | 6 +++--- cmd/pixiu/sidecar.go | 13 +++++++++++-- igt/Makefile | 3 +-- samples/dubbogo/simple/start.sh | 2 +- start.sh | 2 +- 7 files changed, 27 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index e8b7d6227..19da706ad 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ build: cd $(mainPath) && go build -o $(currentPath)/$(targetName) *.go run: build - ./dubbo-go-pixiu start-gateway -a $(api-config-path) -c $(config-path) + ./dubbo-go-pixiu gateway start -a $(api-config-path) -c $(config-path) license-check-util: go install github.com/lsm-dev/license-header-checker/cmd/license-header-checker@latest diff --git a/cmd/pixiu/gateway.go b/cmd/pixiu/gateway.go index 8588516e4..49181aca0 100644 --- a/cmd/pixiu/gateway.go +++ b/cmd/pixiu/gateway.go @@ -32,9 +32,14 @@ import ( ) var ( + gatewayCmd = &cobra.Command{ + Use: "gateway", + Short: "Run dubbo go pixiu in gateway mode", + } + startGatewayCmd = &cobra.Command{ - Use: "start-gateway", - Short: "Run dubbo go pixiu in gateway mode", + Use: "start", + Short: "Start gateway", Version: Version, PreRun: func(cmd *cobra.Command, args []string) { initDefaultValue() @@ -72,4 +77,6 @@ func init() { startGatewayCmd.PersistentFlags().StringVarP(&logLevel, constant.LogLevelKey, "l", os.Getenv(constant.EnvDubbogoPixiuLogLevel), "dubbogo pixiu log level, trace|debug|info|warning|error|critical") startGatewayCmd.PersistentFlags().StringVarP(&limitCpus, constant.LimitCpusKey, "m", os.Getenv(constant.EnvDubbogoPixiuLimitCpus), "dubbogo pixiu schedule threads count") startGatewayCmd.PersistentFlags().StringVarP(&logFormat, constant.LogFormatKey, "f", os.Getenv(constant.EnvDubbogoPixiuLogFormat), "dubbogo pixiu log format, currently useless") + + gatewayCmd.AddCommand(startGatewayCmd) } diff --git a/cmd/pixiu/pixiu.go b/cmd/pixiu/pixiu.go index 2d05fc94d..f5989b0ad 100644 --- a/cmd/pixiu/pixiu.go +++ b/cmd/pixiu/pixiu.go @@ -80,13 +80,13 @@ func getRootCmd() *cobra.Command { Short: "Dubbogo pixiu is a lightweight gateway.", Long: "dubbo-go-pixiu is a gateway that mainly focuses on providing gateway solution to your Dubbo and RESTful \n" + "services. It supports HTTP-to-Dubbo and HTTP-to-HTTP proxy and more protocols will be supported in the near \n" + - "future." + + "future. \n" + "(c) " + strconv.Itoa(time.Now().Year()) + " Dubbogo", Version: Version, } - rootCmd.AddCommand(startGatewayCmd) - rootCmd.AddCommand(startSideCarCmd) + rootCmd.AddCommand(gatewayCmd) + rootCmd.AddCommand(sideCarCmd) return rootCmd } diff --git a/cmd/pixiu/sidecar.go b/cmd/pixiu/sidecar.go index be12b2a6e..f095cf9f8 100644 --- a/cmd/pixiu/sidecar.go +++ b/cmd/pixiu/sidecar.go @@ -23,11 +23,20 @@ import ( ) var ( - startSideCarCmd = &cobra.Command{ - Use: "start-sidecar", + sideCarCmd = &cobra.Command{ + Use: "sidecar", Short: "Run dubbo go pixiu in sidecar mode (implement in the future)", + } + + startSideCarCmd = &cobra.Command{ + Use: "start", + Short: "Start sidecar (implement in the future)", Run: func(cmd *cobra.Command, args []string) { fmt.Println("Meet you in the Future!") }, } ) + +func init() { + sideCarCmd.AddCommand(startSideCarCmd) +} diff --git a/igt/Makefile b/igt/Makefile index d1751708a..d396af866 100644 --- a/igt/Makefile +++ b/igt/Makefile @@ -82,7 +82,6 @@ build: $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME) config .PHONY: $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME) $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME): $(info > Buiding application binary: $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME)) - @echo $(OUT_DIR)/server/$(PROJECT_NAME)$(EXT_NAME) @CGO_ENABLED=$(CGO) GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(GCFLAGS) -ldflags=$(LDFLAGS) -i -o $(OUT_DIR)/server/$(PROJECT_NAME)$(EXT_NAME) $(SOURCES) @@ -134,7 +133,7 @@ run: buildPixiu .PHONY: buildPixiu buildPixiu: @CGO_ENABLED=$(CGO) GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(GCFLAGS) -ldflags=$(LDFLAGS) -i -o $(OUT_DIR)/dubbo-go-pixiu$(EXT_NAME) $(pixiuSources) - @-$(OUT_DIR)/dubbo-go-pixiu$(EXT_NAME) start-gateway -a $(API_CONFIG_PATH) -c $(CONFIG_PATH) & echo $$! > $(PIXIU_PID) + @-$(OUT_DIR)/dubbo-go-pixiu$(EXT_NAME) gateway start -a $(API_CONFIG_PATH) -c $(CONFIG_PATH) & echo $$! > $(PIXIU_PID) @cat $(PIXIU_PID) | sed "/^/s/^/ \> PIXIU_PID: /" ## stop: Stop running the application (for server) .PHONY: stop diff --git a/samples/dubbogo/simple/start.sh b/samples/dubbogo/simple/start.sh index 59adc999c..203239274 100755 --- a/samples/dubbogo/simple/start.sh +++ b/samples/dubbogo/simple/start.sh @@ -22,4 +22,4 @@ DIR=$(cd $(dirname $0) && pwd ) echo $DIR -./dubbo-go-pixiu start-gateway -c ${DIR}/$1/pixiu/conf.yaml -a ${DIR}/$1/pixiu/api_config.yaml \ No newline at end of file +./dubbo-go-pixiu gateway start -c ${DIR}/$1/pixiu/conf.yaml -a ${DIR}/$1/pixiu/api_config.yaml \ No newline at end of file diff --git a/start.sh b/start.sh index 561625328..6dae90039 100755 --- a/start.sh +++ b/start.sh @@ -26,4 +26,4 @@ PROJECT_HOME=${PROJECT_HOME}"/" export CONF_CONSUMER_FILE_PATH=${PROJECT_HOME}"conf/client.yml" export APP_LOG_CONF_FILE=${PROJECT_HOME}"conf/log.yml" -./dubbo-go-pixiu start-gateway ${args} \ No newline at end of file +./dubbo-go-pixiu gateway start ${args} \ No newline at end of file From fac80302dd0763366efd3615358b7df5632c69ae Mon Sep 17 00:00:00 2001 From: MasterKenway Date: Wed, 4 Aug 2021 13:07:50 +0800 Subject: [PATCH 7/8] style: go simple --- cmd/pixiu/pixiu.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/pixiu/pixiu.go b/cmd/pixiu/pixiu.go index f5989b0ad..3353c84f1 100644 --- a/cmd/pixiu/pixiu.go +++ b/cmd/pixiu/pixiu.go @@ -18,7 +18,6 @@ package main import ( - "errors" "fmt" _ "net/http/pprof" "runtime" @@ -130,7 +129,7 @@ func initLog() error { logger.SetLoggerLevel(level) } else { logger.SetLoggerLevel(flagToLogLevel[constant.DefaultLogLevel]) - return errors.New(fmt.Sprintf("logLevel is invalid, set log level to default: %s", constant.DefaultLogLevel)) + return fmt.Errorf("logLevel is invalid, set log level to default: %s", constant.DefaultLogLevel) } return nil } From 3590d67a2d3ba19ec4d3eec4bb485bcb60ccb9bc Mon Sep 17 00:00:00 2001 From: MasterKenway Date: Fri, 6 Aug 2021 15:28:18 +0800 Subject: [PATCH 8/8] feat: readme fit new command --- README.md | 2 +- README_CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b5a1c0f60..b18edeca9 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ go build -o pixiu cmd/pixiu/*.go #### 2.3 Execute the binary file in the project root directory ``` -./pixiu start +./pixiu gateway start ``` ### 3. Try a request diff --git a/README_CN.md b/README_CN.md index 294afa9cb..0e9081236 100644 --- a/README_CN.md +++ b/README_CN.md @@ -69,7 +69,7 @@ go build -o pixiu cmd/pixiu/*.go #### 2.3 启动pixiu,在根目录执行 ``` -./pixiu start +./pixiu gateway start ``` ### 3. 发起请求