-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
54 lines (42 loc) · 1023 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"os"
"os/signal"
"syscall"
"github.com/spf13/cobra"
"github.com/Thoro/bfd-gobgp-connector/logging"
)
func main() {
configPath := ""
cmd := &cobra.Command{
Use: "bfd-gobgp-connector",
Run: func(_ *cobra.Command, _ []string) {
runService(configPath)
},
}
cmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "Path to config file")
cmd.Execute()
}
func runService(configPath string) {
config, err := LoadConfig(configPath)
if err != nil {
panic(err)
}
if len(config.Logging.Logfile) > 0 {
log.SetLogfileName(config.Logging.Logfile)
} else {
log.SetLogfileName("interconnect.log")
}
log.SetLogToStdout(config.Logging.LogToStdout)
service := NewInterconnectService(config)
log.Infof("Starting server, quit using Ctrl+C")
go service.Start()
/* Make server killable by ^C */
chanClose := make(chan os.Signal)
signal.Notify(chanClose, syscall.SIGINT, syscall.SIGTERM)
select {
case <-chanClose:
log.Infof("Shutting down server")
return
}
}