Commit df70fe4a authored by Tommi Virtanen's avatar Tommi Virtanen

Serve expvars and pprof on the API port

parent b1183099
package main
import (
_ "expvar"
"fmt"
"net/http"
_ "net/http/pprof"
"os"
"strings"
......@@ -76,6 +79,17 @@ the port as you would other services or database (firewall, authenticated proxy,
Run: daemonFunc,
}
// defaultMux tells mux to serve path using the default muxer. This is
// mostly useful to hook up things that register in the default muxer,
// and don't provide a convenient http.Handler entry point, such as
// expvar and http/pprof.
func defaultMux(path string) func(node *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) {
return func(node *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) {
mux.Handle(path, http.DefaultServeMux)
return mux, nil
}
}
func daemonFunc(req cmds.Request, res cmds.Response) {
// let the user know we're going.
fmt.Printf("Initializing daemon...\n")
......@@ -281,6 +295,8 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
corehttp.WebUIOption,
gateway.ServeOption(),
corehttp.VersionOption(),
defaultMux("/debug/vars"),
defaultMux("/debug/pprof/"),
}
if rootRedirect != nil {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment