-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (46 loc) · 1012 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
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"
nested "github.com/antonfisher/nested-logrus-formatter"
log "github.com/sirupsen/logrus"
"periph.io/x/host/v3"
"pilarm/core/config"
"pilarm/pilarm"
)
func init() {
Config := config.Get()
logLevel := log.InfoLevel
if Config.Debug {
logLevel = log.DebugLevel
}
log.SetLevel(logLevel)
log.SetFormatter(&nested.Formatter{
HideKeys: true,
FieldsOrder: []string{"component", "category"},
})
if _, err := host.Init(); err != nil {
log.WithField("error", err).Fatal("Could not load drivers")
}
}
func main() {
log.Debug("Starting Pilarm in debug mode")
pilarm, _ := pilarm.NewPilarm()
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
go func() {
<-c
fmt.Println("")
pilarm.Stop()
log.WithField("category", "general").Info("Stopped")
os.Exit(0)
}()
pilarm.Start()
log.WithField("category", "general").Info("Started")
for {
time.Sleep(5 * time.Minute)
}
}