main.go 989 字节
Newer Older
S
sunby 已提交
1
package main
S
sunby 已提交
2 3 4 5 6 7 8

import (
	"context"
	"os"
	"os/signal"
	"syscall"

S
sunby 已提交
9 10
	"github.com/zilliztech/milvus-distributed/internal/logutil"

11 12
	"github.com/zilliztech/milvus-distributed/internal/dataservice"

S
sunby 已提交
13
	"github.com/zilliztech/milvus-distributed/cmd/distributed/components"
14
	"github.com/zilliztech/milvus-distributed/internal/log"
G
groot 已提交
15
	"github.com/zilliztech/milvus-distributed/internal/msgstream/pulsarms"
S
sunby 已提交
16 17 18 19
)

func main() {
	ctx, cancel := context.WithCancel(context.Background())
S
sunby 已提交
20
	defer logutil.LogPanic()
S
sunby 已提交
21

22
	dataservice.Params.Init()
S
sunby 已提交
23
	logutil.SetupLogger(&dataservice.Params.Log)
24
	defer log.Sync()
G
groot 已提交
25 26 27
	msFactory := pulsarms.NewFactory()

	svr, err := components.NewDataService(ctx, msFactory)
S
sunby 已提交
28 29 30
	if err != nil {
		panic(err)
	}
S
sunby 已提交
31
	if err = svr.Run(); err != nil {
S
sunby 已提交
32 33 34 35 36 37 38 39 40 41 42
		panic(err)
	}

	sc := make(chan os.Signal)
	signal.Notify(sc,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)
	<-sc
	cancel()
S
sunby 已提交
43
	if err := svr.Stop(); err != nil {
S
sunby 已提交
44 45
		panic(err)
	}
46
	log.Debug("shut down data service")
S
sunby 已提交
47
}