-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
47 lines (37 loc) · 963 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"
"fmt"
"github.com/op/go-logging"
"os"
)
var log = logging.MustGetLogger("goflake")
var logFormat = logging.MustStringFormatter(
"%{color}%{time:15:04:05.000} %{shortfunc} ▶ %{level:.4s} %{id:03x}%{color:reset} %{message}",
)
var configFile = flag.String("config", "", "TOML config file")
func main() {
// set up logging
logging.SetBackend(logging.NewBackendFormatter(logging.NewLogBackend(os.Stderr, "", 0), logFormat))
// grab our config
flag.Parse()
var c *Config
var err error
if len(*configFile) > 0 {
c, err = NewConfigWithFile(*configFile)
if err != nil {
fmt.Printf("load failover config %s err %v\n", *configFile, err)
return
}
} else {
fmt.Printf("No config file.\n")
fmt.Printf("Please specify with the --config option.\n")
return
}
// and start up the ol' HTTP server
s, err := newServer(c)
if err != nil {
log.Fatalf("could not start http server: %v", err)
}
s.start()
}