mirror of https://github.com/dapr/cli.git
parent
4397421acf
commit
ce7a31b8f6
|
@ -118,3 +118,12 @@ To list all Actions instances running in a Kubernetes cluster:
|
|||
```
|
||||
$ actions list --kubernetes
|
||||
```
|
||||
|
||||
#### Stop
|
||||
|
||||
Use ```actions list``` to get a list of all running instances.
|
||||
To stop an actions app on your machine:
|
||||
|
||||
```
|
||||
$ actions stop --app-id myAppID
|
||||
```
|
||||
|
|
|
@ -154,6 +154,7 @@ var RunCmd = &cobra.Command{
|
|||
AppPort: appPort,
|
||||
Command: strings.Join(args, " "),
|
||||
Created: actionsRunCreatedTime,
|
||||
PID: os.Getpid(),
|
||||
})
|
||||
|
||||
print.SuccessStatusEvent(os.Stdout, "You're up and running! Both Actions and your app logs will appear here.\n")
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/actionscore/cli/pkg/print"
|
||||
"github.com/actionscore/cli/pkg/standalone"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var stopAppID string
|
||||
|
||||
var StopCmd = &cobra.Command{
|
||||
Use: "stop",
|
||||
Short: "Stops a running Actions instance and its associated app",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
err := standalone.Stop(stopAppID)
|
||||
if err != nil {
|
||||
print.FailureStatusEvent(os.Stdout, "failed to stop app id %s: %s", stopAppID, err)
|
||||
} else {
|
||||
print.SuccessStatusEvent(os.Stdout, "app stopped successfully")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
StopCmd.Flags().StringVarP(&stopAppID, "app-id", "", "", "app id to stop (standalone mode)")
|
||||
RootCmd.AddCommand(StopCmd)
|
||||
}
|
|
@ -30,6 +30,7 @@ type RunData struct {
|
|||
AppPort int
|
||||
Command string
|
||||
Created time.Time
|
||||
PID int
|
||||
}
|
||||
|
||||
func AppendRunData(runData *RunData) error {
|
||||
|
|
|
@ -13,6 +13,7 @@ type ListOutput struct {
|
|||
Command string `csv:"COMMAND"`
|
||||
Age string `csv:"AGE"`
|
||||
Created string `csv:"CREATED"`
|
||||
PID int
|
||||
}
|
||||
|
||||
func List() ([]ListOutput, error) {
|
||||
|
@ -30,6 +31,7 @@ func List() ([]ListOutput, error) {
|
|||
ActionsPort: runtimeLine.ActionsPort,
|
||||
Command: utils.TruncateString(runtimeLine.Command, 20),
|
||||
Created: runtimeLine.Created.Format("2006-01-02 15:04.05"),
|
||||
PID: runtimeLine.PID,
|
||||
}
|
||||
if runtimeLine.AppPort > 0 {
|
||||
listRow.AppPort = runtimeLine.AppPort
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package standalone
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func Stop(appID string) error {
|
||||
apps, err := List()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, a := range apps {
|
||||
if a.AppID == appID {
|
||||
pid := fmt.Sprintf("%v", a.PID)
|
||||
if runtime.GOOS == "windows" {
|
||||
err := runCmd("taskkill", "/F", "/PID", pid)
|
||||
return err
|
||||
} else {
|
||||
err := runCmd("kill", pid)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("couldn't find app id %s", appID)
|
||||
}
|
Loading…
Reference in New Issue