github.com/devcamcar/cli@v0.0.0-20181107134215-706a05759d18/commands/stop.go (about) 1 package commands 2 3 import ( 4 "errors" 5 "fmt" 6 "os/exec" 7 8 "github.com/urfave/cli" 9 ) 10 11 // StopCommand returns stop server cli.command 12 func StopCommand() cli.Command { 13 return cli.Command{ 14 Name: "stop", 15 Usage: "Stop a function server", 16 Category: "SERVER COMMANDS", 17 Description: "This command stops a Fn server.", 18 Action: stop, 19 } 20 } 21 func stop(c *cli.Context) error { 22 cmd := exec.Command("docker", "stop", "fnserver") 23 err := cmd.Run() 24 if err != nil { 25 return errors.New("Failed to stop 'fnserver'") 26 } 27 28 fmt.Println("Successfully stopped 'fnserver'") 29 30 return err 31 }