/
main.go
44 lines (34 loc) · 844 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
package main
import (
"log"
"github.com/erichnascimento/cloud-watch/config"
"github.com/erichnascimento/cloud-watch/watch"
"github.com/tj/docopt"
"github.com/tj/go-gracefully"
)
const version = "0.0.1"
const usage = `
Usage:
cloud-watch --config <file>
cloud-watch --help | -h
cloud-watch --version | v
Options:
-c, --config config file to load
-h, --help output help information
-v, --version output version
`
func main() {
args, err := docopt.Parse(usage, nil, true, version, false)
if err != nil {
log.Fatalf("error parsing arguments: %s", err)
}
file := args["<file>"].(string)
c, err := config.New(file)
if err != nil {
log.Fatalf("error loading configuration: %s", err)
}
log.Printf("starting monitor")
watch.NewMonitor(c).Start()
gracefully.Shutdown()
log.Printf("stopping monitor")
}