rename --name to --type; provide empty stores.StorageConfig when init new service
This commit is contained in:
parent
7728d6bfc3
commit
2af02af1c1
@ -53,7 +53,26 @@ var restoreCmd = &cli.Command{
|
|||||||
ctx := lcli.ReqContext(cctx)
|
ctx := lcli.ReqContext(cctx)
|
||||||
log.Info("Initializing lotus miner using a backup")
|
log.Info("Initializing lotus miner using a backup")
|
||||||
|
|
||||||
if err := restore(ctx, cctx, nil, func(api lapi.FullNode, maddr address.Address, peerid peer.ID, mi miner.MinerInfo) error {
|
var storageCfg *stores.StorageConfig
|
||||||
|
if cctx.IsSet("storage-config") {
|
||||||
|
cf, err := homedir.Expand(cctx.String("storage-config"))
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("expanding storage config path: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cfb, err := ioutil.ReadFile(cf)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("reading storage config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
storageCfg = &stores.StorageConfig{}
|
||||||
|
err = json.Unmarshal(cfb, storageCfg)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("cannot unmarshal json for storage config: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := restore(ctx, cctx, storageCfg, nil, func(api lapi.FullNode, maddr address.Address, peerid peer.ID, mi miner.MinerInfo) error {
|
||||||
log.Info("Checking proof parameters")
|
log.Info("Checking proof parameters")
|
||||||
|
|
||||||
if err := paramfetch.GetParams(ctx, build.ParametersJSON(), build.SrsJSON(), uint64(mi.SectorSize)); err != nil {
|
if err := paramfetch.GetParams(ctx, build.ParametersJSON(), build.SrsJSON(), uint64(mi.SectorSize)); err != nil {
|
||||||
@ -75,7 +94,7 @@ var restoreCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func restore(ctx context.Context, cctx *cli.Context, manageConfig func(*config.StorageMiner) error, after func(api lapi.FullNode, addr address.Address, peerid peer.ID, mi miner.MinerInfo) error) error {
|
func restore(ctx context.Context, cctx *cli.Context, strConfig *stores.StorageConfig, manageConfig func(*config.StorageMiner) error, after func(api lapi.FullNode, addr address.Address, peerid peer.ID, mi miner.MinerInfo) error) error {
|
||||||
if cctx.Args().Len() != 1 {
|
if cctx.Args().Len() != 1 {
|
||||||
return xerrors.Errorf("expected 1 argument")
|
return xerrors.Errorf("expected 1 argument")
|
||||||
}
|
}
|
||||||
@ -192,26 +211,12 @@ func restore(ctx context.Context, cctx *cli.Context, manageConfig func(*config.S
|
|||||||
log.Warn("--config NOT SET, WILL USE DEFAULT VALUES")
|
log.Warn("--config NOT SET, WILL USE DEFAULT VALUES")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cctx.IsSet("storage-config") {
|
if strConfig != nil {
|
||||||
log.Info("Restoring storage path config")
|
log.Info("Restoring storage path config")
|
||||||
|
|
||||||
cf, err := homedir.Expand(cctx.String("storage-config"))
|
|
||||||
if err != nil {
|
|
||||||
return xerrors.Errorf("expanding storage config path: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
cfb, err := ioutil.ReadFile(cf)
|
|
||||||
if err != nil {
|
|
||||||
return xerrors.Errorf("reading storage config: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var cerr error
|
|
||||||
err = lr.SetStorage(func(scfg *stores.StorageConfig) {
|
err = lr.SetStorage(func(scfg *stores.StorageConfig) {
|
||||||
cerr = json.Unmarshal(cfb, scfg)
|
*scfg = *strConfig
|
||||||
})
|
})
|
||||||
if cerr != nil {
|
|
||||||
return xerrors.Errorf("unmarshalling storage config: %w", cerr)
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("setting storage config: %w", err)
|
return xerrors.Errorf("setting storage config: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
cliutil "github.com/filecoin-project/lotus/cli/util"
|
cliutil "github.com/filecoin-project/lotus/cli/util"
|
||||||
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||||
"github.com/filecoin-project/lotus/node/config"
|
"github.com/filecoin-project/lotus/node/config"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
@ -30,18 +31,13 @@ var serviceCmd = &cli.Command{
|
|||||||
Usage: "config file (config.toml)",
|
Usage: "config file (config.toml)",
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
|
||||||
Name: "storage-config",
|
|
||||||
Usage: "storage paths config (storage.json)",
|
|
||||||
Required: true,
|
|
||||||
},
|
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "nosync",
|
Name: "nosync",
|
||||||
Usage: "don't check full-node sync status",
|
Usage: "don't check full-node sync status",
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
Name: "name",
|
Name: "type",
|
||||||
Usage: "services to be enabled",
|
Usage: "type of service to be enabled",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "api-sealer",
|
Name: "api-sealer",
|
||||||
@ -57,7 +53,7 @@ var serviceCmd = &cli.Command{
|
|||||||
ctx := lcli.ReqContext(cctx)
|
ctx := lcli.ReqContext(cctx)
|
||||||
log.Info("Initializing lotus miner service")
|
log.Info("Initializing lotus miner service")
|
||||||
|
|
||||||
es := EnabledServices(cctx.StringSlice("name"))
|
es := EnabledServices(cctx.StringSlice("type"))
|
||||||
|
|
||||||
if len(es) == 0 {
|
if len(es) == 0 {
|
||||||
return xerrors.Errorf("at least one module must be enabled")
|
return xerrors.Errorf("at least one module must be enabled")
|
||||||
@ -75,7 +71,7 @@ var serviceCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("--api-sector-index is required without the sector storage module enabled")
|
return xerrors.Errorf("--api-sector-index is required without the sector storage module enabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := restore(ctx, cctx, func(cfg *config.StorageMiner) error {
|
if err := restore(ctx, cctx, &stores.StorageConfig{}, func(cfg *config.StorageMiner) error {
|
||||||
cfg.Subsystems.EnableMarkets = es.Contains(MarketsService)
|
cfg.Subsystems.EnableMarkets = es.Contains(MarketsService)
|
||||||
cfg.Subsystems.EnableMining = false
|
cfg.Subsystems.EnableMining = false
|
||||||
cfg.Subsystems.EnableSealing = false
|
cfg.Subsystems.EnableSealing = false
|
||||||
|
@ -104,9 +104,8 @@ USAGE:
|
|||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
--config value config file (config.toml)
|
--config value config file (config.toml)
|
||||||
--storage-config value storage paths config (storage.json)
|
|
||||||
--nosync don't check full-node sync status (default: false)
|
--nosync don't check full-node sync status (default: false)
|
||||||
--name value services to be enabled
|
--type value type of service to be enabled
|
||||||
--api-sealer value sealer API info (lotus-miner auth api-info --perm=admin)
|
--api-sealer value sealer API info (lotus-miner auth api-info --perm=admin)
|
||||||
--api-sector-index value sector Index API info (lotus-miner auth api-info --perm=admin)
|
--api-sector-index value sector Index API info (lotus-miner auth api-info --perm=admin)
|
||||||
--help, -h show help (default: false)
|
--help, -h show help (default: false)
|
||||||
|
Loading…
Reference in New Issue
Block a user