Merge pull request #807 from estesp/add-pause-resume
Add pause/resume implementation
This commit is contained in:
@@ -59,6 +59,8 @@ containerd client
|
||||
killCommand,
|
||||
pprofCommand,
|
||||
execCommand,
|
||||
pauseCommand,
|
||||
resumeCommand,
|
||||
}
|
||||
app.Commands = append(app.Commands, extraCmds...)
|
||||
app.Before = func(context *cli.Context) error {
|
||||
|
||||
29
cmd/ctr/pause.go
Normal file
29
cmd/ctr/pause.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"errors"
|
||||
|
||||
"github.com/containerd/containerd/api/services/execution"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var pauseCommand = cli.Command{
|
||||
Name: "pause",
|
||||
Usage: "pause an existing container",
|
||||
ArgsUsage: "CONTAINER",
|
||||
Action: func(context *cli.Context) error {
|
||||
containers, err := getExecutionService(context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
id := context.Args().First()
|
||||
if id == "" {
|
||||
return errors.New("container id must be provided")
|
||||
}
|
||||
_, err = containers.Pause(gocontext.Background(), &execution.PauseRequest{
|
||||
ID: id,
|
||||
})
|
||||
return err
|
||||
},
|
||||
}
|
||||
29
cmd/ctr/resume.go
Normal file
29
cmd/ctr/resume.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"errors"
|
||||
|
||||
"github.com/containerd/containerd/api/services/execution"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var resumeCommand = cli.Command{
|
||||
Name: "resume",
|
||||
Usage: "resume a paused container",
|
||||
ArgsUsage: "CONTAINER",
|
||||
Action: func(context *cli.Context) error {
|
||||
containers, err := getExecutionService(context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
id := context.Args().First()
|
||||
if id == "" {
|
||||
return errors.New("container id must be provided")
|
||||
}
|
||||
_, err = containers.Resume(gocontext.Background(), &execution.ResumeRequest{
|
||||
ID: id,
|
||||
})
|
||||
return err
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user