From cfff372541cd72629628edab67fe2369e86a3dbc Mon Sep 17 00:00:00 2001 From: wangjian Date: Wed, 5 Apr 2023 21:01:46 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BE=9D=E8=B5=96=E5=BA=93,=20=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E8=BF=9E=E6=8E=A5=E6=8A=A5=E9=94=99=EF=BC=8C=E5=B0=B1?= =?UTF-8?q?=E4=BC=9A=E6=8B=92=E7=BB=9D=E6=9C=8D=E5=8A=A1=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/server.go | 19 ++++++++++++------- config/config.yaml | 2 ++ go.mod | 35 ++++++++++++++++++++--------------- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/cmd/server.go b/cmd/server.go index d10edf0..ff0737c 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -10,11 +10,13 @@ import ( "syscall" "git.hpds.cc/pavement/hpds_node" - discover "hpds_mq/internal/discover/consul" +) + +const ( + AppLogPrefix = "\033[33m[hpds-mq:app]\033[0m " ) var ( - consulConfigs chan *discover.ConsulConfig ConfigFileFlag string = "./config/config.yml" ConsulAddress string = "http://localhost:8500" NodeName string = "main-node" @@ -23,7 +25,7 @@ var ( func must(err error) { if err != nil { - fmt.Fprint(os.Stderr, err) + _, _ = fmt.Fprint(os.Stderr, err) os.Exit(1) } } @@ -82,11 +84,13 @@ func NewStartCmd() *cobra.Command { mq, err := hpds_node.NewMq(configFileFlag) must(err) mq.InitOptions(hpds_node.WithAuth("token", cfg.Token)) - defer mq.Close() + defer func() { + _ = mq.Close() + }() if len(cfg.CascadeNode) > 0 { for i := 0; i < len(cfg.CascadeNode); i++ { - mq.AddDownstreamMq(hpds_node.NewDownstreamMq( + _ = mq.AddDownstreamMq(hpds_node.NewDownstreamMq( cfg.CascadeNode[i].Name, hpds_node.WithMqAddr(fmt.Sprintf("%s:%d", cfg.CascadeNode[i].Host, cfg.CascadeNode[i].Port)), hpds_node.WithCredential(fmt.Sprintf("token:%s", cfg.CascadeNode[i].Token)), @@ -94,11 +98,12 @@ func NewStartCmd() *cobra.Command { } } // start mq service - log.Printf("Server has started!, pid: %d", os.Getpid()) + log.Infof("%s Server has started!, pid: %d", os.Getpid()) go func() { err = mq.ListenAndServe() if err != nil { - panic(err) + log.Errorf("%s %s error %s", AppLogPrefix, cfg.Name, err.Error()) + os.Exit(-1) } }() select {} diff --git a/config/config.yaml b/config/config.yaml index 29f2122..51af5d8 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -16,6 +16,8 @@ functions: - name: task-request - name: task-response - name: task-execute + - name: dataset-request + - name: capture-agent logging: path: ./logs prefix: mq-node diff --git a/go.mod b/go.mod index e5a3191..26a9209 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module hpds_mq go 1.19 require ( - git.hpds.cc/Component/network v0.0.0-20230402152327-d10a80765e7c - git.hpds.cc/pavement/hpds_node v0.0.0-20230402152619-41414aafa930 + git.hpds.cc/Component/network v0.0.0-20230405125523-abb93c020ff5 + git.hpds.cc/pavement/hpds_node v0.0.0-20230405125907-be7c3e11c61e github.com/hashicorp/consul/api v1.15.3 github.com/spf13/cobra v1.6.0 github.com/spf13/viper v1.13.0 @@ -27,6 +27,7 @@ require ( github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.8 // indirect + github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect github.com/googleapis/gax-go/v2 v2.4.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-hclog v1.2.0 // indirect @@ -37,10 +38,7 @@ require ( github.com/hashicorp/serf v0.9.7 // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/lucas-clemente/quic-go v0.29.1 // indirect github.com/magiconair/properties v1.8.6 // indirect - github.com/marten-seemann/qtls-go1-18 v0.1.2 // indirect - github.com/marten-seemann/qtls-go1-19 v0.1.0 // indirect github.com/matoous/go-nanoid/v2 v2.0.0 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect @@ -48,11 +46,13 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/nxadm/tail v1.4.8 // indirect - github.com/onsi/ginkgo v1.16.4 // indirect + github.com/onsi/ginkgo/v2 v2.2.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/quic-go/qtls-go1-19 v0.2.1 // indirect + github.com/quic-go/qtls-go1-20 v0.1.1 // indirect + github.com/quic-go/quic-go v0.33.0 // indirect github.com/sagikazarmark/crypt v0.6.0 // indirect github.com/spf13/afero v1.8.2 // indirect github.com/spf13/cast v1.5.0 // indirect @@ -67,14 +67,14 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.23.0 // indirect - golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect - golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect - golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect - golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect + golang.org/x/crypto v0.4.0 // indirect + golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect + golang.org/x/mod v0.6.0 // indirect + golang.org/x/net v0.4.0 // indirect golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect - golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect - golang.org/x/text v0.3.7 // indirect - golang.org/x/tools v0.1.10 // indirect + golang.org/x/sys v0.3.0 // indirect + golang.org/x/text v0.5.0 // indirect + golang.org/x/tools v0.2.0 // indirect golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect google.golang.org/api v0.81.0 // indirect google.golang.org/appengine v1.6.7 // indirect @@ -83,6 +83,11 @@ require ( google.golang.org/protobuf v1.28.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect - gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) + +// +//replace ( +// git.hpds.cc/Component/network => ../network +// git.hpds.cc/pavement/hpds_node => ../hpds_node +//)