-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
43 lines (35 loc) · 1.47 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
package main
import (
log "github.com/sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
"os"
)
func main() {
var (
logLevel = kingpin.Flag("loglevel", "Log level: [debug, info, warn, error, fatal]").Short('l').Default("info").String()
timeout = kingpin.Flag("timeout", "Timeout: overall timeout for all collectors").Short('t').Default("0s").Duration()
config = kingpin.Flag("config", "Path to collectors configuration file").Short('c').Required().String()
baseDir = kingpin.Flag("basedir", "Temporary base directory to create the resulting collection tarball").Short('b').Default("/tmp").String()
resultsDir = kingpin.Flag("results-dir", "Directory to store the resulting collection tarball").Short('r').Default(".").String()
dbDir = kingpin.Flag("db-dir", "Path to store the local results database").Default(".").String()
)
kingpin.HelpFlag.Short('h')
kingpin.Parse()
parsedLogLevel, err := log.ParseLevel(*logLevel)
if err != nil {
log.Errorf("Cannot set log level, error: %s", err.Error())
os.Exit(-1)
}
customFormatter := new(log.TextFormatter)
customFormatter.TimestampFormat = "2006-01-02 15:04:05"
customFormatter.FullTimestamp = true
log.SetFormatter(customFormatter)
log.SetLevel(parsedLogLevel)
log.SetOutput(os.Stdout)
scheduler, err := NewScheduler(*config, timeout, *baseDir, *resultsDir, *dbDir)
if err != nil {
log.Errorf("Cannot enable scheduler, exiting, error: %s", err.Error())
os.Exit(-1)
}
log.Fatal(scheduler.Start())
}