-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
47 lines (36 loc) · 863 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
package main
import (
"os"
"github.com/Sirupsen/logrus"
"github.com/kardianos/osext"
)
var (
Log = logrus.New()
)
func main() {
// Set the log output to stderr since communication with ExaBGP is done via stdout.
Log.Out = os.Stderr
path, err := osext.ExecutableFolder()
if err != nil {
Log.WithField("error", err).Fatal(err)
}
opts := ParseOptions()
if *opts.Debug {
Log.Level = logrus.DebugLevel
}
bgp, err := NewBGP(os.Stdin)
if err != nil {
Log.WithField("error", err).Errorf("BGP initialization error")
os.Exit(1)
}
go withPanicLogging(bgp.ReadMessages)
if *opts.HTTPEnable {
go func() {
Log.Infof("Starting HTTP server on port %d", *opts.HTTPPort)
if err := <-StartHTTPServer(*opts.HTTPPort, path); err != nil {
Log.WithField("error", err).Fatal("Error starting HTTP server")
}
}()
}
waitForSignals()
}