-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (40 loc) · 1.07 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
package main
import (
"os"
"os/signal"
"github.com/elastic/beats/libbeat/logp"
"github.com/ogier/pflag"
)
func main() {
configFile := pflag.StringP("config", "c", "log-pulse.yml", "The yaml file to load configuration from")
logLevel := pflag.String("loglevel", "INFO", "The lowest log level you want outputted")
pflag.Parse()
// Initialize our logging
logp.Init("log-pulse", &logp.Logging{
Level: *logLevel,
})
// Load our configuration
configs, rawConfigs, err := ParseConfigFile(*configFile)
if err != nil {
logp.Critical("Unable to parse the config file: %s", err)
os.Exit(1)
}
// Create our Collection
collection, err := CreateCollection(*configs, rawConfigs)
if err != nil {
logp.Critical("Unable to create a collection: %s", err)
os.Exit(1)
}
// Register with exit signals
sigs := make(chan os.Signal, 1)
go func() {
s := <-sigs
logp.Info("Received exit signal: %s", s)
logp.Info("Stopping and cleaning up")
collection.Stop()
}()
signal.Notify(sigs, os.Interrupt, os.Kill)
// Start our process
collection.Start()
collection.LetRun()
}