29dbc26dbd
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
86 lines
1.8 KiB
Go
86 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
"go.opencensus.io/trace"
|
|
|
|
"github.com/filecoin-project/lotus/build"
|
|
lcli "github.com/filecoin-project/lotus/cli"
|
|
"github.com/filecoin-project/lotus/lib/lotuslog"
|
|
"github.com/filecoin-project/lotus/lib/tracing"
|
|
"github.com/filecoin-project/lotus/node/repo"
|
|
)
|
|
|
|
var AdvanceBlockCmd *cli.Command
|
|
|
|
func main() {
|
|
lotuslog.SetupLogLevels()
|
|
|
|
local := []*cli.Command{
|
|
DaemonCmd,
|
|
}
|
|
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,
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "repo",
|
|
EnvVars: []string{"LOTUS_PATH"},
|
|
Hidden: true,
|
|
Value: "~/.lotus", // TODO: Consider XDG_DATA_HOME
|
|
},
|
|
},
|
|
|
|
Commands: append(local, lcli.Commands...),
|
|
}
|
|
app.Setup()
|
|
app.Metadata["traceContext"] = ctx
|
|
app.Metadata["repoType"] = repo.FullNode
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
span.SetStatus(trace.Status{
|
|
Code: trace.StatusCodeFailedPrecondition,
|
|
Message: err.Error(),
|
|
})
|
|
_, ok := err.(*lcli.ErrCmdFailed)
|
|
if ok {
|
|
log.Debugf("%+v", err)
|
|
} else {
|
|
log.Warnf("%+v", err)
|
|
}
|
|
os.Exit(1)
|
|
}
|
|
}
|