-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
49 lines (41 loc) · 858 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
package main
import (
"encoding/json"
"log"
"os"
"os/signal"
)
var config Config
var nSlackChan = make(chan NotificationMessage)
var nLineChan = make(chan NotificationMessage)
func loadConfig() {
configFile, err := os.Open("config.json")
if err != nil {
log.Fatal("Error while opening config.json", err)
}
jsonParser := json.NewDecoder(configFile)
if err = jsonParser.Decode(&config); err != nil {
log.Fatal("Error while parsing config.json", err)
}
}
func main() {
// Load configuration
loadConfig()
// Start notifiers
go slackNotifier()
go lineNotifier()
// Start feed watchers
for _, sub := range config.Subscriptions {
watcher(sub)
}
// Stop when hitting Ctrl-C
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt)
for {
select {
case <-sigChan:
log.Println("Interrupted")
return
}
}
}