forked from cmschuetz/btops
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
42 lines (33 loc) · 682 Bytes
/
main.go
File metadata and controls
42 lines (33 loc) · 682 Bytes
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 (
"log"
"github.com/cmschuetz/btops/config"
"github.com/cmschuetz/btops/handlers"
"github.com/cmschuetz/btops/ipc"
"github.com/cmschuetz/btops/monitors"
)
func main() {
for {
listen()
}
}
func listen() {
c, err := config.GetConfig()
if err != nil {
log.Fatal("Unable to get config", err)
}
log.Println("Config: ", c)
handlers := handlers.NewHandlers(c)
sub, err := ipc.NewSubscriber()
if err != nil {
log.Fatal(err)
}
defer sub.Close()
for !c.ConfigChanged() && sub.Scanner.Scan() {
monitors, err := monitors.GetMonitors()
if err != nil {
log.Println("Unable to obtain monitors:", err)
}
handlers.Handle(monitors)
}
}