[FIX] fix startup sequence control bug

This commit is contained in:
barnett 2019-03-17 14:08:42 +08:00
parent db60916be2
commit 9c4132ba02
2 changed files with 5 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import (
"fmt"
"os"
"strconv"
"strings"
"time"
"github.com/envoyproxy/go-control-plane/envoy/api/v2/core"
@ -80,6 +81,9 @@ func NewDependServiceHealthController() (*DependServiceHealthController, error)
}
if dependCount, err := strconv.Atoi(os.Getenv("DEPEND_SERVICE_COUNT")); err == nil {
dsc.dependServiceCount = dependCount
} else {
depServices := os.Getenv("DEPEND_SERVICE")
dsc.dependServiceCount = len(strings.Split(depServices, ","))
}
dsc.endpointClient = v2.NewEndpointDiscoveryServiceClient(cli)
return &dsc, nil

View File

@ -196,6 +196,7 @@ func createEnv(as *v1.AppService, dbmanager db.Manager) (*[]corev1.EnvVar, error
Depend += fmt.Sprintf("%s:%s", sa.ServiceAlias, sa.ServiceID)
}
envs = append(envs, corev1.EnvVar{Name: "DEPEND_SERVICE", Value: Depend})
envs = append(envs, corev1.EnvVar{Name: "DEPEND_SERVICE_COUNT", Value: strconv.Itoa(len(serviceAliass))})
as.NeedProxy = true
}
}