94 lines
2.1 KiB
Go
94 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
|
|
logging "github.com/ipfs/go-log/v2"
|
|
"github.com/mattn/go-isatty"
|
|
"github.com/urfave/cli/v2"
|
|
"go.opencensus.io/trace"
|
|
|
|
"github.com/filecoin-project/lotus/api"
|
|
"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 log = logging.Logger("main")
|
|
|
|
var AdvanceBlockCmd *cli.Command
|
|
|
|
func main() {
|
|
api.RunningNodeType = api.NodeFull
|
|
|
|
lotuslog.SetupLogLevels()
|
|
|
|
local := []*cli.Command{
|
|
DaemonCmd,
|
|
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()
|
|
|
|
interactiveDef := isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd())
|
|
|
|
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
|
|
},
|
|
&cli.BoolFlag{
|
|
Name: "interactive",
|
|
Usage: "setting to false will disable interactive functionality of commands",
|
|
Value: interactiveDef,
|
|
},
|
|
&cli.BoolFlag{
|
|
Name: "force-send",
|
|
Usage: "if true, will ignore pre-send checks",
|
|
},
|
|
},
|
|
|
|
Commands: append(local, lcli.Commands...),
|
|
}
|
|
|
|
app.Setup()
|
|
app.Metadata["traceContext"] = ctx
|
|
app.Metadata["repoType"] = repo.FullNode
|
|
|
|
lcli.RunApp(app)
|
|
}
|