-
Notifications
You must be signed in to change notification settings - Fork 455
/
Copy pathmain.go
52 lines (43 loc) · 1.1 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
package main
import (
"fmt"
"github.com/bytedance/Elkeid/server/agent_center/common"
"github.com/bytedance/Elkeid/server/agent_center/common/ylog"
"github.com/bytedance/Elkeid/server/agent_center/grpctrans"
"github.com/bytedance/Elkeid/server/agent_center/httptrans"
"github.com/bytedance/Elkeid/server/agent_center/svr_registry"
"net/http"
_ "net/http/pprof"
"os/signal"
"syscall"
)
func init() {
signal.Notify(common.Sig, syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL)
}
func main() {
ylog.Infof("[MAIN]", "START_SERVER")
//start http server and grpc server
go httptrans.Run()
go grpctrans.Run()
//start pprof for debug
go debug()
//register to service discovery center
regGrpc := svr_registry.NewGRPCServerRegistry()
defer func() {
regGrpc.Stop()
}()
regHttp := svr_registry.NewHttpServerRegistry()
defer func() {
regHttp.Stop()
}()
<-common.Sig
}
func debug() {
//start pprof for debug
if common.PProfEnable {
err := http.ListenAndServe(fmt.Sprintf(":%d", common.PProfPort), nil)
if err != nil {
ylog.Errorf("[MAIN]", "pprof ListenAndServe Error %s", err.Error())
}
}
}