-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (45 loc) · 1.23 KB
/
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
55
package main
import (
"flag"
"github.com/clemens97/scion-path-oracle/server"
"go.uber.org/zap"
"log"
"os"
"os/signal"
"syscall"
)
func main() {
var (
listen string
listenMonitor string
)
flag.StringVar(&listen, "listen", ":443", "Listening address for the path oracle.")
flag.StringVar(&listenMonitor, "listenMonitoring", ":8080", "Non-SCION listening address for real time monitoring.")
flag.Parse()
signalChannel := make(chan os.Signal, 2)
signal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM)
logger, err := zap.NewDevelopment()
if err != nil {
log.Fatalf("could not initialize logger: %s", err)
}
defer logger.Sync()
slogger := logger.Sugar()
go func() {
handleSignals(signalChannel, slogger)
}()
oracle, err := server.New(listen, listenMonitor, slogger)
if err != nil {
slogger.Fatalw("error setting up path oracle", "error", err)
}
slogger.Infow("starting path oracle", "listen", listen, "listenMonitor", listenMonitor)
err = oracle.Start()
if err != nil {
slogger.Fatalw("error running path oracle", "error", err)
}
}
func handleSignals(sigChan chan os.Signal, logger *zap.SugaredLogger) {
for sig := range sigChan {
logger.Infow("captured signal, exiting", "signal", sig)
os.Exit(0)
}
}