main.go 1.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.

12 13 14 15 16 17 18 19
package main

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

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

N
neza2017 已提交
22
	distributed "github.com/zilliztech/milvus-distributed/cmd/distributed/components"
N
neza2017 已提交
23 24
	"github.com/zilliztech/milvus-distributed/internal/log"
	"github.com/zilliztech/milvus-distributed/internal/masterservice"
X
Xiangyu Wang 已提交
25
	"github.com/zilliztech/milvus-distributed/internal/msgstream"
N
neza2017 已提交
26
	"go.uber.org/zap"
27 28 29 30 31 32
)

func main() {
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

N
neza2017 已提交
33
	masterservice.Params.Init()
S
sunby 已提交
34
	logutil.SetupLogger(&masterservice.Params.Log)
N
neza2017 已提交
35 36 37 38 39 40
	defer func() {
		if err := log.Sync(); err != nil {
			panic(err)
		}
	}()

X
Xiangyu Wang 已提交
41
	msFactory := msgstream.NewPmsFactory()
G
groot 已提交
42
	ms, err := distributed.NewMasterService(ctx, msFactory)
43 44 45
	if err != nil {
		panic(err)
	}
N
neza2017 已提交
46
	if err = ms.Run(); err != nil {
47 48 49 50 51 52 53 54 55 56
		panic(err)
	}

	sc := make(chan os.Signal, 1)
	signal.Notify(sc,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)
	sig := <-sc
B
bigsheeper 已提交
57
	log.Debug("Get signal to exit", zap.String("signal", sig.String()))
N
neza2017 已提交
58 59 60 61
	err = ms.Stop()
	if err != nil {
		panic(err)
	}
62
}