mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
Fix data service init
Signed-off-by: neza2017 <yefu.chen@zilliz.com>
This commit is contained in:
parent
d1b23cb8c5
commit
4d37a329da
@ -9,12 +9,13 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
ms "github.com/zilliztech/milvus-distributed/internal/distributed/masterservice"
|
||||
|
||||
"github.com/zilliztech/milvus-distributed/internal/masterservice"
|
||||
|
||||
"github.com/zilliztech/milvus-distributed/internal/distributed/dataservice"
|
||||
|
||||
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb2"
|
||||
|
||||
"github.com/zilliztech/milvus-distributed/internal/distributed/masterservice"
|
||||
"github.com/zilliztech/milvus-distributed/internal/master"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -22,8 +23,8 @@ func main() {
|
||||
|
||||
service := dataservice.NewGrpcService(ctx)
|
||||
|
||||
master.Params.Init()
|
||||
client, err := masterservice.NewGrpcClient(fmt.Sprintf("%s:%d", master.Params.Address, master.Params.Port), 30*time.Second)
|
||||
masterservice.Params.Init()
|
||||
client, err := ms.NewGrpcClient(fmt.Sprintf("%s:%d", masterservice.Params.Address, masterservice.Params.Port), 30*time.Second)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/zilliztech/milvus-distributed/internal/distributed/masterservice"
|
||||
|
||||
@ -43,6 +44,7 @@ func (s *Service) SetMasterClient(masterClient dataservice.MasterClient) {
|
||||
}
|
||||
|
||||
func (s *Service) Init() error {
|
||||
var err error
|
||||
s.grpcServer = grpc.NewServer()
|
||||
datapb.RegisterDataServiceServer(s.grpcServer, s)
|
||||
lis, err := net.Listen("tcp", fmt.Sprintf("%s:%d", dataservice.Params.Address, dataservice.Params.Port))
|
||||
@ -50,9 +52,20 @@ func (s *Service) Init() error {
|
||||
log.Fatal(err.Error())
|
||||
return nil
|
||||
}
|
||||
if err = s.grpcServer.Serve(lis); err != nil {
|
||||
log.Fatal(err.Error())
|
||||
return nil
|
||||
c := make(chan struct{})
|
||||
go func() {
|
||||
if err2 := s.grpcServer.Serve(lis); err2 != nil {
|
||||
log.Println(err.Error())
|
||||
close(c)
|
||||
err = err2
|
||||
}
|
||||
}()
|
||||
timer := time.NewTimer(1 * time.Second)
|
||||
select {
|
||||
case <-timer.C:
|
||||
break
|
||||
case <-c:
|
||||
return err
|
||||
}
|
||||
return s.server.Init()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user