-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
47 lines (36 loc) · 850 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
package main
import (
"flag"
"io/ioutil"
"strconv"
"github.com/ghodss/yaml"
"github.com/sirupsen/logrus"
)
var version = "undefined"
func main() {
formatter := &logrus.TextFormatter{
FullTimestamp: true,
}
logrus.SetFormatter(formatter)
a := app{}
flag.IntVar(&a.Port, "port", 8000, "Application port")
var config = flag.String("config", "config.yaml", "Config file path")
flag.Parse()
file, err := ioutil.ReadFile(*config)
if err != nil {
logrus.Fatal(err)
}
if err := yaml.Unmarshal(file, &a); err != nil {
logrus.Fatal(err)
}
if err := a.Initialize(); err != nil {
logrus.Fatal(err)
}
logrus.WithFields(logrus.Fields{
"redis": a.Redis.Hostname + ":" + strconv.Itoa(a.Redis.Port),
"version": version,
}).Info("Countme is running on :", a.Port)
if err := a.Run(); err != nil {
logrus.Fatal(err)
}
}