Added 'killall' command for convenience

master
xSmurf 10 years ago
parent c827fa981f
commit 5a2b5ab375

@ -94,6 +94,10 @@ func runApplication() {
Name: "kill", Name: "kill",
Action: handleKill, Action: handleKill,
}, },
{
Name: "killall",
Action: handleKillall,
},
{ {
Name: "logs", Name: "logs",
Action: handleLogs, Action: handleLogs,
@ -196,6 +200,13 @@ func getSandboxById(id int) (*daemon.SandboxInfo, error) {
return nil, nil return nil, nil
} }
func handleKillall(c *cli.Context) {
if err := daemon.KillAllSandboxes(); err != nil {
fmt.Fprintf(os.Stderr, "Killall command failed: %s.\n", err)
os.Exit(1)
}
}
func handleKill(c *cli.Context) { func handleKill(c *cli.Context) {
if len(c.Args()) == 0 { if len(c.Args()) == 0 {
fmt.Fprintf(os.Stderr, "Need a sandbox id to kill\n") fmt.Fprintf(os.Stderr, "Need a sandbox id to kill\n")
@ -203,7 +214,7 @@ func handleKill(c *cli.Context) {
} }
if c.Args()[0] == "all" { if c.Args()[0] == "all" {
if err := daemon.KillAllSandboxes(); err != nil { if err := daemon.KillAllSandboxes(); err != nil {
fmt.Fprintf(os.Stderr, "Kill command failed: %s.\n", err) fmt.Fprintf(os.Stderr, "Killall command failed: %s.\n", err)
os.Exit(1) os.Exit(1)
} }
return return

Loading…
Cancel
Save