-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathmain.go
52 lines (42 loc) · 942 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
50
51
52
package main
import (
"flag"
"io"
"log"
"net/http"
_ "net/http/pprof"
"os"
)
type GlobalConfig struct {
PoolSize int
}
var logs *log.Logger
func DefaultGC() *GlobalConfig {
gc := new(GlobalConfig)
gc.PoolSize = 1000
return gc
}
func main() {
c := flag.String("c", "gofluent.conf", "config filepath")
p := flag.String("p", "", "write cpu profile to file")
v := flag.String("v", "error.log", "log file path")
flag.Parse()
f, err := os.OpenFile(*v, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalln("os.Open failed, err:", err)
}
defer f.Close()
w := io.MultiWriter(f, os.Stdout)
logs = log.New(w, "", log.Ldate|log.Ltime|log.Lshortfile)
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
log.SetOutput(w)
if *p != "" {
go func() {
log.Println(http.ListenAndServe("0.0.0.0:"+*p, nil))
}()
}
gc := DefaultGC()
config := NewPipeLineConfig(gc)
config.LoadConfig(*c)
Run(config)
}