-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (34 loc) · 775 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
package main
import (
"log"
"os"
"os/signal"
"syscall"
"github.com/ethereum/go-ethereum/ethclient"
)
func main() {
listen := os.Getenv("LISTEN")
configFile := os.Getenv("CONFIG_FILE")
config, err := ReadConfig(configFile)
if err != nil {
log.Println("can't read config:", err)
os.Exit(1)
}
watcher := Watcher{
geth: map[string]*ethclient.Client{},
items: map[string][]*watchItem{},
}
if err := watcher.LoadConfig(config); err != nil {
log.Println("can't load config:", err)
os.Exit(1)
}
if err := watcher.Start(listen); err != nil {
log.Println("can't start watcher:", err)
os.Exit(1)
}
sigterm := make(chan os.Signal, 1)
signal.Notify(sigterm, os.Interrupt, syscall.SIGTERM)
log.Println("Started")
<- sigterm
log.Println("Stop")
}