fix grpc port collision, add warnings (#37)

This commit is contained in:
Yaron Schneider 2019-08-16 12:52:40 -07:00 committed by GitHub
parent a612f4cf4d
commit 9209c23ac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 2 deletions

View File

@ -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)