Make pprof optional

This commit is contained in:
Qian Wang 2019-01-21 11:49:01 +00:00
parent b522d4a407
commit 3fb8f0656e
1 changed files with 10 additions and 4 deletions

View File

@ -185,10 +185,6 @@ func dispatchConnection(conn net.Conn, sta *server.State) {
}
func main() {
runtime.SetBlockProfileRate(5)
go func() {
log.Println(http.ListenAndServe("0.0.0.0:8001", nil))
}()
// Should be 127.0.0.1 to listen to ss-server on this machine
var localHost string
// server_port in ss config, same as remotePort in plugin mode
@ -218,6 +214,8 @@ func main() {
genUID := flag.Bool("u", false, "Generate a UID")
genKeyPair := flag.Bool("k", false, "Generate a pair of public and private key, output in the format of pubkey,pvkey")
pprofAddr := flag.String("d", "", "debug use: ip:port to be listened by pprof profiler")
flag.Parse()
if *askVersion {
@ -238,6 +236,14 @@ func main() {
return
}
if *pprofAddr != "" {
runtime.SetBlockProfileRate(5)
go func() {
log.Println(http.ListenAndServe(*pprofAddr, nil))
}()
log.Println("pprof listening on " + *pprofAddr)
}
if *localAddr == "" {
log.Fatal("Must specify localAddr")
}