lotus/cmd/lotus/main.go

76 lines
1.6 KiB
Go
Raw Normal View History

package main
import (
"context"
"github.com/urfave/cli/v2"
"go.opencensus.io/trace"
"github.com/filecoin-project/lotus/build"
lcli "github.com/filecoin-project/lotus/cli"
2020-01-08 13:49:34 +00:00
"github.com/filecoin-project/lotus/lib/lotuslog"
2020-02-22 11:36:22 +00:00
"github.com/filecoin-project/lotus/lib/tracing"
"github.com/filecoin-project/lotus/node/repo"
)
var AdvanceBlockCmd *cli.Command
func main() {
build.RunningNodeType = build.NodeFull
2020-01-08 13:49:34 +00:00
lotuslog.SetupLogLevels()
2019-10-29 19:51:44 +00:00
local := []*cli.Command{
2019-07-18 23:16:23 +00:00
DaemonCmd,
2020-10-01 15:14:08 +00:00
backupCmd,
}
if AdvanceBlockCmd != nil {
local = append(local, AdvanceBlockCmd)
}
jaeger := tracing.SetupJaegerTracing("lotus")
defer func() {
if jaeger != nil {
jaeger.Flush()
}
}()
for _, cmd := range local {
cmd := cmd
originBefore := cmd.Before
cmd.Before = func(cctx *cli.Context) error {
trace.UnregisterExporter(jaeger)
jaeger = tracing.SetupJaegerTracing("lotus/" + cmd.Name)
if originBefore != nil {
return originBefore(cctx)
}
return nil
}
}
ctx, span := trace.StartSpan(context.Background(), "/cli")
defer span.End()
app := &cli.App{
Name: "lotus",
Usage: "Filecoin decentralized storage network client",
Version: build.UserVersion(),
EnableBashCompletion: true,
2019-07-10 17:10:19 +00:00
Flags: []cli.Flag{
&cli.StringFlag{
Name: "repo",
EnvVars: []string{"LOTUS_PATH"},
Hidden: true,
Value: "~/.lotus", // TODO: Consider XDG_DATA_HOME
},
2019-07-08 19:07:16 +00:00
},
Commands: append(local, lcli.Commands...),
}
app.Setup()
app.Metadata["traceContext"] = ctx
app.Metadata["repoType"] = repo.FullNode
lcli.RunApp(app)
}