mirror of https://github.com/dapr/cli.git
fix grpc port collision, add warnings (#37)
This commit is contained in:
parent
a612f4cf4d
commit
9209c23ac3
|
@ -67,11 +67,18 @@ func getActionsCommand(appID string, actionsPort int, appPort int) (*exec.Cmd, i
|
|||
|
||||
if runtime.GOOS == "windows" {
|
||||
args = append(args, "localhost:6050")
|
||||
args = append(args, "--actions-grpc-port", "6051")
|
||||
} else {
|
||||
args = append(args, "localhost:50005")
|
||||
}
|
||||
|
||||
args = append(args, "--actions-grpc-port")
|
||||
grpcPort, err := freeport.GetFreePort()
|
||||
if err != nil {
|
||||
return nil, -1, err
|
||||
}
|
||||
|
||||
args = append(args, fmt.Sprintf("%v", grpcPort))
|
||||
|
||||
cmd := exec.Command(actionsCMD, args...)
|
||||
return cmd, actionsPort, nil
|
||||
}
|
||||
|
@ -152,7 +159,18 @@ func Run(config *RunConfig) (*RunOutput, error) {
|
|||
appID = strings.Replace(sillyname.GenerateStupidName(), " ", "-", -1)
|
||||
}
|
||||
|
||||
err := createRedisStateStore()
|
||||
actions, err := List()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, a := range actions {
|
||||
if appID == a.AppID {
|
||||
return nil, fmt.Errorf("actions with ID %s is already running", appID)
|
||||
}
|
||||
}
|
||||
|
||||
err = createRedisStateStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -167,6 +185,12 @@ func Run(config *RunConfig) (*RunOutput, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
for _, a := range actions {
|
||||
if actionsPort == a.ActionsPort {
|
||||
return nil, fmt.Errorf("there's already an actions instance running with port %v", actionsPort)
|
||||
}
|
||||
}
|
||||
|
||||
runArgs := []string{}
|
||||
argCount := len(config.Arguments)
|
||||
|
||||
|
|
Loading…
Reference in New Issue