-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (35 loc) · 948 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
package main
import (
"flag"
"os"
"github.com/aau-network-security/haaukins-daemon/internal/daemon"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
const (
defaultConfigFile = "config/config.yml"
)
var (
version = "dev"
compileDate = "unknown"
)
func main() {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
confFilePtr := flag.String("config", defaultConfigFile, "configuration file")
flag.Parse()
log.Info().Str("version", version).Str("compileDate", compileDate).Msg("Starting HAAUKINS Daemon")
c, err := daemon.NewConfigFromFile(*confFilePtr)
if err != nil {
log.Fatal().Err(err).Msgf("unable to read configuration file: %s", *confFilePtr)
return
}
d, err := daemon.New(c)
if err != nil {
log.Fatal().Err(err).Msg("unable to create daemon")
return
}
if err := d.Run(); err != nil {
log.Fatal().Err(err).Msg("Error running daemon")
}
}