-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (48 loc) · 1.06 KB
/
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
53
package main
import (
"flag"
"fmt"
"github.com/ljy2010a/tailf-based-sampling/compactor"
"github.com/ljy2010a/tailf-based-sampling/receiver"
//_ "go.uber.org/automaxprocs"
"math/rand"
"runtime"
"time"
)
func main() {
fmt.Println(
VERSION,
time.Now().Format("2006-01-02 15:04:05"),
time.Now().Unix(),
runtime.NumCPU(),
runtime.GOMAXPROCS(-1),
)
//defer func() {
// err := recover()
// if err != nil {
// fmt.Println(err)
// time.Sleep(10 * time.Second)
// }
//}()
rand.Seed(time.Now().Unix())
var httpPort string
flag.StringVar(&httpPort, "p", "", "port")
flag.Parse()
if httpPort == "8000" || httpPort == "8001" {
receiver := receiver.Receiver{
HttpPort: httpPort,
CompactorPort: "8002",
CompactorSetWrongUrl: fmt.Sprintf("http://127.0.0.1:8002/sw"),
}
runtime.GOMAXPROCS(2)
receiver.Run()
} else if httpPort == "8002" {
compactor := compactor.Compactor{
HttpPort: httpPort,
}
runtime.GOMAXPROCS(1 * 2)
compactor.Run()
}
fmt.Printf("port not macth [%v] \n", httpPort)
time.Sleep(10 * time.Second)
}