2019-06-25 11:42:17 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-07-25 20:19:43 +00:00
|
|
|
"context"
|
2019-06-25 11:42:17 +00:00
|
|
|
|
2020-06-02 18:12:53 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2019-07-25 20:19:43 +00:00
|
|
|
"go.opencensus.io/trace"
|
2019-06-25 11:42:17 +00:00
|
|
|
|
2019-10-18 04:47:41 +00:00
|
|
|
"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"
|
2019-12-09 12:36:56 +00:00
|
|
|
"github.com/filecoin-project/lotus/node/repo"
|
2019-06-25 11:42:17 +00:00
|
|
|
)
|
|
|
|
|
2020-01-29 22:39:48 +00:00
|
|
|
var AdvanceBlockCmd *cli.Command
|
|
|
|
|
2019-06-25 11:42:17 +00:00
|
|
|
func main() {
|
2020-09-08 18:54:37 +00:00
|
|
|
build.RunningNodeType = build.NodeFull
|
|
|
|
|
2020-01-08 13:49:34 +00:00
|
|
|
lotuslog.SetupLogLevels()
|
2019-10-29 19:51:44 +00:00
|
|
|
|
2019-06-25 11:42:17 +00:00
|
|
|
local := []*cli.Command{
|
2019-07-18 23:16:23 +00:00
|
|
|
DaemonCmd,
|
2020-10-01 15:14:08 +00:00
|
|
|
backupCmd,
|
2019-06-25 11:42:17 +00:00
|
|
|
}
|
2020-01-29 22:39:48 +00:00
|
|
|
if AdvanceBlockCmd != nil {
|
|
|
|
local = append(local, AdvanceBlockCmd)
|
|
|
|
}
|
|
|
|
|
2019-07-25 20:19:43 +00:00
|
|
|
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()
|
2019-06-25 11:42:17 +00:00
|
|
|
|
|
|
|
app := &cli.App{
|
2020-06-02 18:12:53 +00:00
|
|
|
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
|
|
|
},
|
2019-06-25 11:42:17 +00:00
|
|
|
|
|
|
|
Commands: append(local, lcli.Commands...),
|
|
|
|
}
|
2019-07-25 20:19:43 +00:00
|
|
|
app.Setup()
|
|
|
|
app.Metadata["traceContext"] = ctx
|
2019-12-09 12:36:56 +00:00
|
|
|
app.Metadata["repoType"] = repo.FullNode
|
2019-06-25 11:42:17 +00:00
|
|
|
|
2020-07-23 19:31:28 +00:00
|
|
|
lcli.RunApp(app)
|
2019-06-25 11:42:17 +00:00
|
|
|
}
|