queryservice.go 1.6 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
package main

import (
	"context"
16 17 18
	"os"
	"os/signal"
	"syscall"
19

X
Xiangyu Wang 已提交
20
	"github.com/milvus-io/milvus/internal/logutil"
S
sunby 已提交
21

B
bigsheeper 已提交
22 23
	"go.uber.org/zap"

X
Xiangyu Wang 已提交
24 25 26 27
	distributed "github.com/milvus-io/milvus/cmd/distributed/components"
	"github.com/milvus-io/milvus/internal/log"
	"github.com/milvus-io/milvus/internal/msgstream"
	"github.com/milvus-io/milvus/internal/queryservice"
28 29 30 31 32 33
)

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

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

X
Xiangyu Wang 已提交
42
	msFactory := msgstream.NewPmsFactory()
G
groot 已提交
43 44

	svr, err := distributed.NewQueryService(ctx, msFactory)
45
	if err != nil {
46 47 48
		panic(err)
	}

49
	if err := svr.Run(); err != nil {
50 51 52
		panic(err)
	}

53 54 55 56 57 58 59
	sc := make(chan os.Signal, 1)
	signal.Notify(sc,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)
	sig := <-sc
B
bigsheeper 已提交
60
	log.Debug("Get signal to exit", zap.String("signal", sig.String()))
61 62 63 64

	if err := svr.Stop(); err != nil {
		panic(err)
	}
65
}