-
Notifications
You must be signed in to change notification settings - Fork 178
/
kiteq.go
58 lines (50 loc) · 1.06 KB
/
kiteq.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
package main
import (
"context"
"fmt"
"kiteq/server"
_ "net/http/pprof"
"os"
"os/signal"
"runtime"
"runtime/debug"
"syscall"
"time"
"github.com/blackbeans/turbo"
)
func main() {
//加载启动参数
so := server.Parse()
runtime.GOMAXPROCS(runtime.NumCPU()*2 + 1)
rc := turbo.NewTConfig(
"remoting",
1000, 16*1024,
16*1024, 10000, 10000,
10*time.Second,
100*10000)
kc := server.NewKiteQConfig(so, rc)
ctx, cancel := context.WithCancel(context.Background())
qserver := server.NewKiteQServer(ctx, kc)
qserver.Start()
var s = make(chan os.Signal, 1)
signal.Notify(s, syscall.SIGKILL, syscall.SIGUSR1, syscall.SIGTERM)
//是否收到kill的命令
for {
cmd := <-s
if cmd == syscall.SIGKILL || cmd == syscall.SIGTERM {
break
} else if cmd == syscall.SIGUSR1 {
//如果为siguser1则进行dump内存
unixtime := time.Now().Unix()
path := fmt.Sprintf("./heapdump-kiteq-%d", unixtime)
f, err := os.Create(path)
if nil != err {
continue
} else {
debug.WriteHeapDump(f.Fd())
}
}
}
qserver.Shutdown()
cancel()
}