2019-07-18 23:16:23 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2020-01-08 19:10:57 +00:00
|
|
|
logging "github.com/ipfs/go-log/v2"
|
2019-07-26 19:01:02 +00:00
|
|
|
"go.opencensus.io/trace"
|
2019-07-18 23:16:23 +00:00
|
|
|
"gopkg.in/urfave/cli.v2"
|
|
|
|
|
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-07-18 23:16:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var log = logging.Logger("main")
|
|
|
|
|
2019-07-23 21:50:52 +00:00
|
|
|
const FlagStorageRepo = "storagerepo"
|
|
|
|
|
2019-07-18 23:16:23 +00:00
|
|
|
func main() {
|
2020-01-08 13:49:34 +00:00
|
|
|
lotuslog.SetupLogLevels()
|
2019-10-29 19:51:44 +00:00
|
|
|
|
2019-07-18 23:16:23 +00:00
|
|
|
local := []*cli.Command{
|
2020-03-04 02:49:00 +00:00
|
|
|
dealsCmd,
|
2019-10-11 23:47:29 +00:00
|
|
|
infoCmd,
|
2020-02-08 00:18:14 +00:00
|
|
|
initCmd,
|
2020-03-06 05:32:52 +00:00
|
|
|
rewardsCmd,
|
2020-02-08 00:18:14 +00:00
|
|
|
runCmd,
|
2019-07-27 21:08:10 +00:00
|
|
|
sectorsCmd,
|
2020-03-09 06:13:22 +00:00
|
|
|
storageCmd,
|
2020-02-08 00:18:14 +00:00
|
|
|
setPriceCmd,
|
2020-03-23 14:56:22 +00:00
|
|
|
workersCmd,
|
2020-04-17 22:02:04 +00:00
|
|
|
provingCmd,
|
2019-07-18 23:16:23 +00:00
|
|
|
}
|
2019-07-26 19:01:02 +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
|
|
|
|
}
|
|
|
|
}
|
2019-07-18 23:16:23 +00:00
|
|
|
|
|
|
|
app := &cli.App{
|
2020-04-08 12:54:06 +00:00
|
|
|
Name: "lotus-storage-miner",
|
|
|
|
Usage: "Filecoin decentralized storage network storage miner",
|
2020-06-01 18:43:51 +00:00
|
|
|
Version: build.UserVersion(),
|
2020-04-03 02:03:53 +00:00
|
|
|
EnableShellCompletion: true,
|
2019-07-18 23:16:23 +00:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "repo",
|
|
|
|
EnvVars: []string{"LOTUS_PATH"},
|
|
|
|
Hidden: true,
|
|
|
|
Value: "~/.lotus", // TODO: Consider XDG_DATA_HOME
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2019-07-23 21:50:52 +00:00
|
|
|
Name: FlagStorageRepo,
|
2019-07-18 23:44:59 +00:00
|
|
|
EnvVars: []string{"LOTUS_STORAGE_PATH"},
|
2019-07-18 23:16:23 +00:00
|
|
|
Value: "~/.lotusstorage", // TODO: Consider XDG_DATA_HOME
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-03-23 12:29:24 +00:00
|
|
|
Commands: append(local, lcli.CommonCommands...),
|
2019-07-18 23:16:23 +00:00
|
|
|
}
|
2019-12-09 12:36:56 +00:00
|
|
|
app.Setup()
|
|
|
|
app.Metadata["repoType"] = repo.StorageMiner
|
2019-07-18 23:16:23 +00:00
|
|
|
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
2019-11-27 11:57:52 +00:00
|
|
|
log.Warnf("%+v", err)
|
2019-11-12 23:36:49 +00:00
|
|
|
os.Exit(1)
|
2019-07-18 23:16:23 +00:00
|
|
|
}
|
|
|
|
}
|