From e46da5a1812efd54723eae3949bd40cb2dba9731 Mon Sep 17 00:00:00 2001 From: Mak Muftic Date: Fri, 24 Sep 2021 12:37:16 +0200 Subject: [PATCH] Add cli flags --- cmd/lotus/daemon.go | 28 ++++++++++++++++++++++++++++ node/config/doc_gen.go | 12 ++++++++++++ node/config/types.go | 1 + node/modules/dtypes/tracer.go | 6 ++++++ 4 files changed, 47 insertions(+) create mode 100644 node/modules/dtypes/tracer.go diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index 486ac8ed7..89901a6f5 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -153,6 +153,22 @@ var DaemonCmd = &cli.Command{ Name: "restore-config", Usage: "config file to use when restoring from backup", }, + &cli.StringFlag{ + Name: "trace-to-json", + Usage: "starts tracer and outputs to json file defined with this flag", + }, + &cli.StringFlag{ + Name: "trace-to-elasticsearch", + Usage: "starts tracer and outputs to elasticsearch, flag must contain connection string for elasticsearch", + }, + &cli.StringFlag{ + Name: "elasticsearch-index", + Usage: "configure elasticearch index name if elasticsearch tracer is configured", + }, + &cli.StringFlag{ + Name: "trace-source-auth", + Usage: "auth token for trusted source of traces", + }, }, Action: func(cctx *cli.Context) error { isLite := cctx.Bool("lite") @@ -193,6 +209,14 @@ var DaemonCmd = &cli.Command{ return fmt.Errorf("unrecognized profile type: %q", profile) } + traceToJsonFile := cctx.String("trace-to-json") + + traceToElasticsearch := cctx.String("trace-to-elasticsearch") + + elasticsearchIndex := cctx.String("elasticsearch-index") + + traceSourceAuth := cctx.String("trace-source-auth") + ctx, _ := tag.New(context.Background(), tag.Insert(metrics.Version, build.BuildVersion), tag.Insert(metrics.Commit, build.CurrentCommit), @@ -319,6 +343,10 @@ var DaemonCmd = &cli.Command{ node.Override(new(dtypes.Bootstrapper), isBootstrapper), node.Override(new(dtypes.ShutdownChan), shutdownChan), + node.Override(new(dtypes.JsonTracerFile), traceToJsonFile), + node.Override(new(dtypes.ElasticSearchTracer), traceToElasticsearch), + node.Override(new(dtypes.ElasticSearchTracer), elasticsearchIndex), + node.Override(new(dtypes.TracerSourceAuth), traceSourceAuth), genesis, liteModeDeps, diff --git a/node/config/doc_gen.go b/node/config/doc_gen.go index fd4ec0366..f22156170 100644 --- a/node/config/doc_gen.go +++ b/node/config/doc_gen.go @@ -537,6 +537,18 @@ Type: Array of multiaddress peerinfo strings, must include peerid (/p2p/12D3K... Name: "ElasticSearchTracer", Type: "string", + Comment: ``, + }, + { + Name: "ElasticSearchIndex", + Type: "string", + + Comment: ``, + }, + { + Name: "TracerSourceAuth", + Type: "string", + Comment: ``, }, }, diff --git a/node/config/types.go b/node/config/types.go index aa061baef..630ae61fd 100644 --- a/node/config/types.go +++ b/node/config/types.go @@ -311,6 +311,7 @@ type Pubsub struct { RemoteTracer string JsonTracerFile string ElasticSearchTracer string + ElasticSearchIndex string TracerSourceAuth string } diff --git a/node/modules/dtypes/tracer.go b/node/modules/dtypes/tracer.go new file mode 100644 index 000000000..9317924f7 --- /dev/null +++ b/node/modules/dtypes/tracer.go @@ -0,0 +1,6 @@ +package dtypes + +type JsonTracerFile string +type ElasticSearchTracer string +type ElasticSearchIndex string +type TracerSourceAuth string