Logging & error handling
[ealt-edge.git] / mecm / mepm / applcm / k8shelm / cmd / helm / main.go
1 /*
2  * Copyright 2020 Huawei Technologies Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package main
18
19 import (
20         "github.com/sirupsen/logrus"
21         "k8shelm/pkg/plugin"
22         "os"
23 )
24
25 const (
26         serverPort = 50051
27         certificate = ""
28         key = ""
29         logFile = "/go/release/logfile"
30         loggerLevel = logrus.InfoLevel
31 )
32
33 func main() {
34         // Prepare logger
35         file, err := os.Create(logFile)
36         if err != nil {
37                 logrus.Fatal(err)
38         }
39         defer file.Close()
40
41         var logger = plugin.GetLogger(logFile, loggerLevel, file)
42
43         // Create GRPC server
44         serverConfig := plugin.ServerGRPCConfig{Certificate: certificate, Port:serverPort, Key:key, Logger:logger}
45         server := plugin.NewServerGRPC(serverConfig)
46
47         // Start listening
48         err = server.Listen()
49         if err != nil {
50                 logger.Fatalf("failed to listen: %v", err)
51         }
52 }