support env overwrite instance ttl
@@ -36,10 +36,15 @@ import (
serviceUtil "github.com/apache/servicecomb-service-center/server/service/util"
"golang.org/x/net/context"
"math"
+ "os"
"strconv"
"time"
)
+var (
+ ttlFromEnv, _ = strconv.ParseInt(os.Getenv("INSTANCE_TTL"), 10, 0)
+)
+
type InstanceService struct {
}
@@ -137,6 +142,9 @@ func (s *InstanceService) Register(ctx context.Context, in *pb.RegisterInstanceR
}
ttl := int64(instance.HealthCheck.Interval * (instance.HealthCheck.Times + 1))
+ if ttlFromEnv > 0 {
+ ttl = ttlFromEnv
+ }
instanceFlag := fmt.Sprintf("ttl %ds, endpoints %v, host '%s', serviceId %s",
ttl, instance.Endpoints, instance.HostName, instance.ServiceId)
