-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
worker: Commands to pause/resume task processing
- Loading branch information
Showing
6 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/urfave/cli/v2" | ||
"golang.org/x/xerrors" | ||
|
||
lcli "github.com/filecoin-project/lotus/cli" | ||
) | ||
|
||
var setCmd = &cli.Command{ | ||
Name: "set", | ||
Usage: "Manage worker settings", | ||
Flags: []cli.Flag{ | ||
&cli.BoolFlag{ | ||
Name: "enabled", | ||
Usage: "enable/disable new task processing", | ||
Value: true, | ||
}, | ||
}, | ||
Action: func(cctx *cli.Context) error { | ||
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{ | ||
Name: "wait-quiet", | ||
Usage: "Block until all running tasks exit", | ||
Action: func(cctx *cli.Context) error { | ||
api, closer, err := lcli.GetWorkerAPI(cctx) | ||
if err != nil { | ||
return err | ||
} | ||
defer closer() | ||
|
||
ctx := lcli.ReqContext(cctx) | ||
|
||
return api.WaitQuiet(ctx) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,8 @@ func main() { | |
runCmd, | ||
infoCmd, | ||
storageCmd, | ||
setCmd, | ||
waitQuietCmd, | ||
} | ||
|
||
app := &cli.App{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters