2015-08-15 05:19:10 +08:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
2017-03-08 10:02:39 +08:00
|
|
|
import "github.com/urfave/cli"
|
2015-08-15 05:19:10 +08:00
|
|
|
|
|
|
|
var pauseCommand = cli.Command{
|
|
|
|
Name: "pause",
|
|
|
|
Usage: "pause suspends all processes inside the container",
|
2017-03-08 10:02:39 +08:00
|
|
|
ArgsUsage: `<container-id>
|
2016-02-11 01:30:06 +08:00
|
|
|
|
|
|
|
Where "<container-id>" is the name for the instance of the container to be
|
|
|
|
paused. `,
|
|
|
|
Description: `The pause command suspends all processes in the instance of the container.
|
|
|
|
|
|
|
|
Use runc list to identiy instances of containers and their current status.`,
|
2016-05-10 13:58:09 +08:00
|
|
|
Action: func(context *cli.Context) error {
|
2017-03-08 10:02:39 +08:00
|
|
|
if err := checkArgs(context, 1, exactArgs); err != nil {
|
2016-10-28 23:43:10 +08:00
|
|
|
return err
|
2016-09-24 21:25:13 +08:00
|
|
|
}
|
2017-03-08 10:02:39 +08:00
|
|
|
container, err := getContainer(context)
|
2015-08-15 05:19:10 +08:00
|
|
|
if err != nil {
|
2016-05-10 13:58:09 +08:00
|
|
|
return err
|
2015-08-15 05:19:10 +08:00
|
|
|
}
|
2017-03-08 10:02:39 +08:00
|
|
|
if err := container.Pause(); err != nil {
|
|
|
|
return err
|
2016-09-24 21:25:13 +08:00
|
|
|
}
|
|
|
|
|
2016-05-10 13:58:09 +08:00
|
|
|
return nil
|
2015-08-15 05:19:10 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var resumeCommand = cli.Command{
|
|
|
|
Name: "resume",
|
2016-02-07 21:57:58 +08:00
|
|
|
Usage: "resumes all processes that have been previously paused",
|
2017-03-08 10:02:39 +08:00
|
|
|
ArgsUsage: `<container-id>
|
2016-02-11 01:30:06 +08:00
|
|
|
|
|
|
|
Where "<container-id>" is the name for the instance of the container to be
|
|
|
|
resumed.`,
|
|
|
|
Description: `The resume command resumes all processes in the instance of the container.
|
|
|
|
|
|
|
|
Use runc list to identiy instances of containers and their current status.`,
|
2016-05-10 13:58:09 +08:00
|
|
|
Action: func(context *cli.Context) error {
|
2017-03-08 10:02:39 +08:00
|
|
|
if err := checkArgs(context, 1, exactArgs); err != nil {
|
2016-10-28 23:43:10 +08:00
|
|
|
return err
|
2016-09-24 21:25:13 +08:00
|
|
|
}
|
2017-03-08 10:02:39 +08:00
|
|
|
container, err := getContainer(context)
|
2015-08-15 05:19:10 +08:00
|
|
|
if err != nil {
|
2016-05-10 13:58:09 +08:00
|
|
|
return err
|
2015-08-15 05:19:10 +08:00
|
|
|
}
|
2017-03-08 10:02:39 +08:00
|
|
|
if err := container.Resume(); err != nil {
|
|
|
|
return err
|
2016-09-24 21:25:13 +08:00
|
|
|
}
|
|
|
|
|
2016-05-10 13:58:09 +08:00
|
|
|
return nil
|
2015-08-15 05:19:10 +08:00
|
|
|
},
|
|
|
|
}
|