-
Notifications
You must be signed in to change notification settings - Fork 25
/
main.go
42 lines (39 loc) · 1.1 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
package main
import (
"flag"
"fmt"
"github.com/bobtfish/AWSnycast/daemon"
"github.com/bobtfish/AWSnycast/version"
log "github.com/sirupsen/logrus"
logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
"log/syslog"
"os"
)
var (
debug = flag.Bool("debug", false, "Enable debugging")
f = flag.String("f", "/etc/awsnycast.yaml", "Configration file")
oneshot = flag.Bool("oneshot", false, "Run route table manipulation exactly once, ignoring healthchecks, then exit")
noop = flag.Bool("noop", false, "Don't actually *do* anything, just print what would be done")
printVersion = flag.Bool("version", false, "Print the version number")
logToSyslog = flag.Bool("syslog", false, "Log to syslog")
)
func main() {
flag.Parse()
if *printVersion {
fmt.Printf("%s\n", version.Version)
os.Exit(0)
}
d := new(daemon.Daemon)
if *debug {
log.SetLevel(log.DebugLevel)
}
if *logToSyslog {
hook, err := logrus_syslog.NewSyslogHook("", "", syslog.LOG_INFO, "")
if err == nil {
log.AddHook(hook)
}
}
d.Debug = *debug
d.ConfigFile = *f
os.Exit(d.Run(*oneshot, *noop))
}