-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.go
69 lines (55 loc) · 1.53 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"flag"
"log"
"math/rand"
"net/http"
_ "net/http/pprof"
"os"
"runtime/pprof"
"time"
"mesh-agent/config"
"mesh-agent/logger"
"mesh-agent/server"
)
func DumpCpuInfo(seconds int) {
f, err := os.Create(*config.ProfileDir + *config.Mode + "_cpuprof.prof")
if err != nil {
return
}
pprof.StartCPUProfile(f)
time.Sleep((time.Duration)(seconds) * time.Second)
pprof.StopCPUProfile()
}
func main() {
rand.Seed(int64(time.Now().UnixNano()))
flag.Parse()
//runtime.GOMAXPROCS(*config.MaxProcs)
//go recordEvent()
config.ProfileLogger = logger.GetProfileLogger(*config.Mode, *config.ProfileDir)
config.ProfileGCLogger = logger.GetProfileGCLogger(*config.Mode, *config.ProfileDir)
if *config.DebugFlag {
go DumpCpuInfo(180)
go func() {
if *config.Mode == "consumer" {
log.Println(http.ListenAndServe("localhost:8088", nil))
} else {
log.Println(http.ListenAndServe("localhost:8089", nil))
}
}()
}
if *config.Mode == "consumer" {
server.GlobalRemoteAgentManager.ServeConnectAgent()
time.Sleep(time.Second)
server.LocalHttpServer(*config.ConsumerHttpLoops, *config.LocalPort)
time.Sleep(time.Second)
go server.GlobalRemoteAgentManager.ListenInterface(server.GlobalInterface)
} else {
server.GlobalLocalDubboAgent.ServeConnectDubbo()
time.Sleep(time.Second)
server.LocalAgentServer(*config.ProviderAgentLoops, *config.ProviderPort)
time.Sleep(time.Second)
go server.GlobalRemoteAgentManager.RegisterInterface(server.GlobalInterface, *config.ProviderPort)
}
select {}
}