2020-10-27 16:28:44 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-02-23 08:46:06 +00:00
|
|
|
"fmt"
|
|
|
|
|
2020-10-27 16:28:44 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"golang.org/x/xerrors"
|
|
|
|
|
|
|
|
lcli "github.com/filecoin-project/lotus/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var setCmd = &cli.Command{
|
2023-03-03 13:13:35 +00:00
|
|
|
Name: "set",
|
|
|
|
Usage: "Manage worker settings",
|
|
|
|
Hidden: true,
|
2020-10-27 16:28:44 +00:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
&cli.BoolFlag{
|
|
|
|
Name: "enabled",
|
|
|
|
Usage: "enable/disable new task processing",
|
|
|
|
Value: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Action: func(cctx *cli.Context) error {
|
2023-03-03 13:13:35 +00:00
|
|
|
fmt.Println("DEPRECATED: This command will be removed in the future")
|
2020-10-27 16:28:44 +00:00
|
|
|
api, closer, err := lcli.GetWorkerAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer closer()
|
|
|
|
|
|
|
|
ctx := lcli.ReqContext(cctx)
|
|
|
|
|
|
|
|
if err := api.SetEnabled(ctx, cctx.Bool("enabled")); err != nil {
|
|
|
|
return xerrors.Errorf("SetEnabled: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var waitQuietCmd = &cli.Command{
|
2023-02-23 08:46:06 +00:00
|
|
|
Name: "wait-quiet",
|
|
|
|
Usage: "Block until all running tasks exit",
|
|
|
|
Hidden: true,
|
2020-10-27 16:28:44 +00:00
|
|
|
Action: func(cctx *cli.Context) error {
|
2023-02-23 08:46:06 +00:00
|
|
|
fmt.Println("DEPRECATED: This command will be removed in the future")
|
2020-10-27 16:28:44 +00:00
|
|
|
api, closer, err := lcli.GetWorkerAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer closer()
|
|
|
|
|
|
|
|
ctx := lcli.ReqContext(cctx)
|
|
|
|
|
|
|
|
return api.WaitQuiet(ctx)
|
|
|
|
},
|
|
|
|
}
|