forked from cyfdecyf/cow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
69 lines (58 loc) · 1.11 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"
"os"
"os/signal"
"runtime"
"syscall"
// "syscall"
// "runtime/pprof"
)
var sigChan = make(chan os.Signal, 1)
// var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
func sigHandler() {
for sig := range sigChan {
info.Printf("%v caught, exit\n", sig)
writeDomainSet()
if logBuf != nil {
logBuf.Flush()
}
break
}
os.Exit(0)
}
func main() {
// Parse flags after load config to allow override options in config
loadConfig()
flag.Parse()
if printVer {
printVersion()
os.Exit(0)
}
initLog()
/*
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
info.Println(err)
os.Exit(1)
}
pprof.StartCPUProfile(f)
signal.Notify(c, os.Interrupt)
go func() {
for sig := range c {
info.Printf("captured %v, stopping profiler and exiting..", sig)
pprof.StopCPUProfile()
os.Exit(0)
}
}()
}
*/
runtime.GOMAXPROCS(config.numProc)
signal.Notify(sigChan, syscall.SIGINT)
signal.Notify(sigChan, syscall.SIGTERM)
go sigHandler()
go runSSH()
py := NewProxy(config.listenAddr)
py.Serve()
}