golanggohlsrtmpwebrtcmedia-serverobs-studiortcprtmp-proxyrtmp-serverrtprtsprtsp-proxyrtsp-relayrtsp-serversrtstreamingwebrtc-proxy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
667 B
46 lines
667 B
package main |
|
|
|
import ( |
|
"context" |
|
"net" |
|
"net/http" |
|
_ "net/http/pprof" |
|
) |
|
|
|
const ( |
|
pprofAddress = ":9999" |
|
) |
|
|
|
type pprof struct { |
|
listener net.Listener |
|
server *http.Server |
|
} |
|
|
|
func newPprof(p *program) (*pprof, error) { |
|
listener, err := net.Listen("tcp", pprofAddress) |
|
if err != nil { |
|
return nil, err |
|
} |
|
|
|
pp := &pprof{ |
|
listener: listener, |
|
} |
|
|
|
pp.server = &http.Server{ |
|
Handler: http.DefaultServeMux, |
|
} |
|
|
|
p.log("[pprof] opened on " + pprofAddress) |
|
return pp, nil |
|
} |
|
|
|
func (pp *pprof) run() { |
|
err := pp.server.Serve(pp.listener) |
|
if err != http.ErrServerClosed { |
|
panic(err) |
|
} |
|
} |
|
|
|
func (pp *pprof) close() { |
|
pp.server.Shutdown(context.Background()) |
|
}
|
|
|